编译的问题collect2: ld returned 1 exit status

[root@bio biology_gpu]# make -f Makefile-test
/usr/local/cuda/bin/nvcc -c -arch=sm_13 -O3 -c -Xptxas -v -o computeSim_kernel.o computeSim_kernel.cu
ptxas info : Compiling entry function ‘_Z17ComputeSim_KernelPdS_S_PiS0_S_S0_S0_ii’ for ‘sm_13’
ptxas info : Used 10 registers, 2120+16 bytes smem, 4 bytes cmem[1]
/usr/local/cuda/bin/nvcc -c -arch=sm_13 -O3 -c -Xptxas -v -o AlgorithmNBM.o AlgorithmNBM.cu
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.4.4/…/…/…/…/include/c++/4.4.4/ext/hash_map:60,
from AlgorithmNBM.h:9,
from AlgorithmNBM.cu:9:
/usr/lib/gcc/x86_64-redhat-linux/4.4.4/…/…/…/…/include/c++/4.4.4/backward/backward_warning.h:28:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated.
AlgorithmNBM.cu(468): warning: variable “start” was set but never used

AlgorithmNBM.cu(468): warning: variable “finish” was declared but never referenced

AlgorithmNBM.cu(469): warning: variable “duration” was declared but never referenced

AlgorithmNBM.cu(1040): warning: variable “count_1” was declared but never referenced

In file included from /usr/lib/gcc/x86_64-redhat-linux/4.4.4/…/…/…/…/include/c++/4.4.4/ext/hash_map:60,
from AlgorithmNBM.h:9,
from AlgorithmNBM.cu:9:
/usr/lib/gcc/x86_64-redhat-linux/4.4.4/…/…/…/…/include/c++/4.4.4/backward/backward_warning.h:28:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated.
AlgorithmNBM.cu(468): warning: variable “start” was set but never used

AlgorithmNBM.cu(468): warning: variable “finish” was declared but never referenced

AlgorithmNBM.cu(469): warning: variable “duration” was declared but never referenced

AlgorithmNBM.cu(1040): warning: variable “count_1” was declared but never referenced

ptxas info : Compiling entry function ‘_Z17ComputeSim_KernelPdS_S_PiS0_S_S0_S0_ii’ for ‘sm_13’
ptxas info : Used 10 registers, 2120+16 bytes smem, 4 bytes cmem[1]
g++ -c -O3 -o biology.o biology.cpp
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.4.4/…/…/…/…/include/c++/4.4.4/ext/hash_map:60,
from AlgorithmNBM.h:9,
from biology.cpp:7:
/usr/lib/gcc/x86_64-redhat-linux/4.4.4/…/…/…/…/include/c++/4.4.4/backward/backward_warning.h:28:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated.
g++ -c -O3 -o stdafx.o stdafx.cpp
g++ -c -O3 -o util.o util.cpp
g++ -c -O3 -o XJEdge.o XJEdge.cpp
g++ -c -O3 -o XJEdgeList.o XJEdgeList.cpp
g++ -c -O3 -o XJFileStream.o XJFileStream.cpp
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.4.4/…/…/…/…/include/c++/4.4.4/backward/strstream:47,
from XJFileStream.cpp:3:
/usr/lib/gcc/x86_64-redhat-linux/4.4.4/…/…/…/…/include/c++/4.4.4/backward/backward_warning.h:28:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated.
g++ -c -O3 -o XJHomogen.o XJHomogen.cpp
g++ -c -O3 -o XJHomogenMap.o XJHomogenMap.cpp
g++ -c -O3 -o XJNode.o XJNode.cpp
g++ -c -O3 -o XJNodeList.o XJNodeList.cpp
g++ -c -O3 -o XJScore.o XJScore.cpp
g++ -o my_exe computeSim_kernel.o AlgorithmNBM.o biology.o stdafx.o util.o XJEdge.o XJEdgeList.o XJFileStream.o XJHomogen.o XJHomogenMap.o XJNode.o XJNodeList.o XJScore.o -L /usr/local/cuda/lib64 -lcudart
AlgorithmNBM.o: In function ComputeSim_Kernel(double*, double*, double*, int*, int*, double*, int*, int*, int, int)': tmpxft_000057c0_00000000-1_AlgorithmNBM.cudafe1.cpp:(.text+0x1c0): multiple definition of ComputeSim_Kernel(double*, double*, double*, int*, int*, double*, int*, int*, int, int)’
computeSim_kernel.o:tmpxft_00005799_00000000-1_computeSim_kernel.cudafe1.cpp:(.text+0x1c0): first defined here
AlgorithmNBM.o: In function __device_stub__Z17ComputeSim_KernelPdS_S_PiS0_S_S0_S0_ii(double*, double*, double*, int*, int*, double*, int*, int*, int, int)': tmpxft_000057c0_00000000-1_AlgorithmNBM.cudafe1.cpp:(.text+0x80): multiple definition of __device_stub__Z17ComputeSim_KernelPdS_S_PiS0_S_S0_S0_ii(double*, double*, double*, int*, int*, double*, int*, int*, int, int)’
computeSim_kernel.o:tmpxft_00005799_00000000-1_computeSim_kernel.cudafe1.cpp:(.text+0x80): first defined here
collect2: ld returned 1 exit status
make: *** [my_exe] Error 1
[root@bio biology_gpu]#

make的时候老是报这个错
我google了一下,有的人说是需要为这个cu文件定义一个头文件
我也定义了,但是还是不行
求大虾帮忙啊

我已经解决了这个问题,我为核函数写了一个头文件,并且把函数都标记为inline
这个错误就OK了
但是我不知道为什么?
有人知道吗?

这个错误是因为一个函数在link时发现了多次重复定义。这与cuda没有直接关系。任何一个c++函数如果在多个文件中重复定义了link时都会报这个错。

是 由于我在主机端函数中多次调用了该核函数?