这些命令是通过Makefile生成的,我基本上是从NVIDIA的教程页面中复制的;它的长度超过100行,如果你认为它是必要的,它会发布它,但这些命令足以重现错误。CUDA链接错误
g++ -m64 -I/usr/local/cuda/include -I. -I.. -I../../common/inc -I/usr/local/cuda/lib64 -o shallowwater.o -c shallowwater.cpp
/usr/local/cuda/bin/nvcc -m64 -gencode arch=compute_10,code=sm_10 -gencode arch=compute_20,code=sm_20 -I/usr/local/cuda/include -I. -I.. -I../../common/inc -I/usr/local/cuda/lib64 -o shallowwatercudamain.o -c shallowwatercudamain.cu
g++ -m64 -o shallowwater shallowwater.o shallowwatercudamain.o -L -lcudart
前两项工作;有选择这两种源文件没有编译错误,但运行第三个命令时,我得到以下错误:
shallowwatercudamain.o: In function `__cudaUnregisterBinaryUtil()':
tmpxft_00004e70_00000000-4_shallowwatercudamain.compute_20.cudafe1.cpp:(.text+0x36): undefined reference to `__cudaUnregisterFatBinary'
shallowwatercudamain.o: In function `__sti____cudaRegisterAll_66_tmpxft_00004e70_00000000_6_shallowwatercudamain_compute_20_cpp1_ii_runIt()':
tmpxft_00004e70_00000000-4_shallowwatercudamain.compute_20.cudafe1.cpp:(.text+0x46): undefined reference to `__cudaRegisterFatBinary'
collect2: ld returned 1 exit status
make: *** [shallowwater] Error 1
下面是一些相关的系统信息:
[[email protected] code]$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2012 NVIDIA Corporation
Built on Thu_Apr__5_00:24:31_PDT_2012
Cuda compilation tools, release 4.2, V0.2.1221
[[email protected] code]$ uname -a
Linux intel19 2.6.32-71.el6.x86_64 #1 SMP Wed Sep 1 01:33:01 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux
我发现有人在这里看到类似的错误,看到这里:/usr/bin/ld: cannot find -lcudart 我很尴尬地说,我发现这一点,做了同样的变化,除了g ++而不是gfortran,它的工作。之后,我又试了一次,但没有成功。我得到相同的错误:
g++ -m64 -o shallowwater shallowwater.o shallowwatercudamain.o -L -L/usr/local/cuda/lib64
这是做到了。谢谢!我想我试图复制它时只是读了修正错误。我正在修复我的Makefile来完成这项工作。 – 2013-05-07 01:24:00