小编Vey*_* Wu的帖子

在 CUDA C 中使用 open() 时出错

我尝试在 CUDA C 中打开文件

fd = open("stats.txt", O_CREAT)
Run Code Online (Sandbox Code Playgroud)

open() 应该在主机端运行,编译通过但存在链接错误。

In function `open':
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:45: undefined reference to `__open_too_many_args'
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)

令我惊讶的是,在谷歌上搜索并没有提供任何接近的信息。有谁有任何提示如何解决这个问题?多谢!


是的,我实际上用的是 0644,抱歉打错了。我将程序简化如下,但仍然出现链接错误。

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <cuda.h>
#include <sys/types.h>
#include <fcntl.h>
int main(int argc, char ** argv) {
  int fd;
  if((fd = open("stats.txt",O_CREAT|O_RDWR, 0644)) == -1) { printf("Can't open stats.txt.\n"); }
  else printf("stats.txt opened.\n");
  return 0;
}

nvcc  -c -arch sm_20 --keep --compiler-options -fno-strict-aliasing  -I/usr/local/cuda/include/ -I../NVIDIA_GPU_Computing_SDK/C/common/inc/ -I../../libcuda -L../NVIDIA_GPU_Computing_SDK/C/lib -lcutil -DUNIX …
Run Code Online (Sandbox Code Playgroud)

c cuda system-calls

2
推荐指数
1
解决办法
3948
查看次数

标签 统计

c ×1

cuda ×1

system-calls ×1