kernel multiple definitions/linking problem simple code will compile but won't link

I have a simple program for solving the heat equaition. It consists of a host code heat.cu, a kernel heat_kernel.cu and a header heat.h. I try to compile and link using

nvcc -o run heat.cu heat_kernel.cu

and I get the following error message:

/tmp/tmpxft_00004991_00000000-24_heat_kernel.o: In function __device_stub__Z10heatevolvePiPf': tmpxft_00004991_00000000-23_heat_kernel.ii:(.text+0x6b9e): multiple definition of __device_stub__Z10heatevolvePiPf’
/tmp/tmpxft_00004991_00000000-15_heat.o:tmpxft_00004991_00000000-14_heat.ii:(.text+0x6b9e): first defined here
collect2: ld returned 1 exit status

It seems like its compiling OK but the linking is failing. I have no idea what this error message means. Anybody have any ideas?

Is your setup copied and pasted from one of the NVIDIA samples that would put “#include <heat_kernel.cu>” at the top of heat.cu? That would explay the multiply defined symbol.

That did it - Thanks!

Hi guys:
I have the same problem.
And yes, I copied and pasted nvidia setup, and put “heat_kernel.cu” at the top of “heat.cu”
You said that that was the problem.

So, how did you solve it?
Did you erase that line (that didn’t work for me)? Or did you do something else?

Your help is appreciated,

Daniel.

Hi Daniel,

I encountered this issue myself. I don’t know if you’re still in need of a solution for this problem, but you can find a solution here:

http://forums.nvidia.com/index.php?showtopic=165849

Hope this helps,
Matt