Here is the deal.
I compile RayBuffer.cu using…
[kost@lancia PovRay]$ nvcc -o obj/release/RayBuffer.cu_o -c RayBuffer.cu -I. -I/usr/local/cuda/include -I…/…/common/inc -DUNIX -O3
I then compile testbuffer.cu using…
[kost@lancia PovRay]$ nvcc -o obj/release/testbuffer.cu_o -c testbuffer.cu -I. -I/usr/local/cuda/include -I…/…/common/inc -DUNIX -O3
then i fail to link the two together to create an executable…
[kost@lancia PovRay]$ g++ -fPIC -o …/…/bin/linux/release/RayBuffer obj/release/RayBuffer.cu_o obj/release/testbuffer.cu_o -L/usr/local/cuda/lib -L…/…/lib -L…/…/common/lib -lcuda -lcudart -lGL -lGLU -lcutil
obj/release/testbuffer.cu_o(.text+0x531e): In function
main': : undefined reference to CSphereBuffer::CSphereBuffer()’
obj/release/testbuffer.cu_o(.text+0x5345): In function
main': : undefined reference to CBoxBuffer::CBoxBuffer()’
obj/release/testbuffer.cu_o(.text+0x536b): In function
main': : undefined reference to CPlaneBuffer::CPlaneBuffer()’
collect2: ld returned 1 exit status
and if i comment out all the cuda code rename to *.C and do the following…
[kost@lancia PovRay] g++ -c testbuffer.C
[kost@lancia PovRay] g++ -c RayBuffer.C
[kost@lancia PovRay]$ g++ -o testbuffer RayBuffer.o testbuffer.o
it works. So there is something with linking two *.cu object that I don’t understand.
Everything works fine if I have the main() in RayBuffer.cu. I can intersect objects on the GPU. But when I move the main() to testbuffer.cu, compile the two *.cu files, then try to link and build an executable, for some reason it does not work. I even tried to create a shared library which has RayBuffer.cu in it. I then include that library in the last step above and I get the same results.
I also tried converting to c code using nvcc -cuda, then doing the same steps. i get the same results. I also tried externing. Same results.
Anyone have any ideas on how to successfully link to *.cu objects together? Or know what else I am doing wrong?