Hello:
I’m new to this stuff. I’m working on a large cpp project that involves .cpp, .h, and data files stored across several folders. I’m using RedHat Linux 5.4 with CUDA 2.2.
I tried to include a CUDA function (defined in a .cu file) in my cpp code. I modified the Makefile and got bazillion errors. Then I read your posts and tried to first generate the object files with nvcc and then link all them together with g++. It didn’t work. I thought it was something with my code, so in order to discard that, I took the ‘cppIntegration’ files and generated the object files with nvcc and tried to link all them together with g++. IT DOES NOT WORK!
I read the posts and applied all your suggestions (extern “C” for instance, although that’s done in the ‘cppIntegration’ files).
This is my series of commands:
nvcc -arch sm_13 --host-compilation c++ -I. -I/usr/local/cuda/include -I/home/drl/NVIDIA_CUDA_SDK/common/inc -L/usr/local/cuda/lib -L/home/drl/NVIDIA_CUDA_SDK/lib -L/home/drl/NVIDIA_CUDA_SDK/common/lib/linux -c *.cu
g++ -o svm *.o *.cpp -I. -I/usr/local/cuda/include -I/home/drl/NVIDIA_CUDA_SDK/common/inc -L/usr/local/cuda/lib -L/home/drl/NVIDIA_CUDA_SDK/lib -L/home/drl/NVIDIA_CUDA_SDK/common/lib/linux -lcuda -lcudart -lcutil
And this is the result I got:
cppIntegration.o: In function kernel2__entry(int2*)': tmpxft_00005ed7_00000000-14_cppIntegration.ii:(.text+0x1c8): multiple definition of
kernel2__entry(int2*)’
cppIntegration_kernel.o:tmpxft_00005ed7_00000000-22_cppIntegration_kernel.ii:(.text+0x1c8): first defined here
cppIntegration.o: In function kernel__entry(int*)': tmpxft_00005ed7_00000000-14_cppIntegration.ii:(.text+0x238): multiple definition of
kernel__entry(int*)’
cppIntegration_kernel.o:tmpxft_00005ed7_00000000-22_cppIntegration_kernel.ii:(.text+0x238): first defined here
cppIntegration.o: In function __device_stub__Z7kernel2P4int2': tmpxft_00005ed7_00000000-14_cppIntegration.ii:(.text+0x170): multiple definition of
__device_stub__Z7kernel2P4int2’
cppIntegration_kernel.o:tmpxft_00005ed7_00000000-22_cppIntegration_kernel.ii:(.text+0x170): first defined here
cppIntegration.o: In function __device_stub__Z6kernelPi': tmpxft_00005ed7_00000000-14_cppIntegration.ii:(.text+0x1e0): multiple definition of
__device_stub__Z6kernelPi’
cppIntegration_kernel.o:tmpxft_00005ed7_00000000-22_cppIntegration_kernel.ii:(.text+0x1e0): first defined here
/tmp/ccs8H011.o: In function computeGold': cppIntegration_gold.cpp:(.text+0x0): multiple definition of
computeGold’
cppIntegration_gold.o:cppIntegration_gold.cpp:(.text+0x0): first defined here
/tmp/ccs8H011.o: In function computeGold2': cppIntegration_gold.cpp:(.text+0x40): multiple definition of
computeGold2’
cppIntegration_gold.o:cppIntegration_gold.cpp:(.text+0x40): first defined here
/tmp/cckgma36.o: In function main': main.cpp:(.text+0x6c): multiple definition of
main’
main.o:main.cpp:(.text+0x6c): first defined here
collect2: ld returned 1 exit status
This is really driving me crazy. I tried everything and it seems that there is a problem with the kernel functions!.
What really bugs me is that the cppIntegration projects works with the supplied Makefile.
Please, I really need your help.
Daniel.