How to reuse kernels in multiple files (for unit testing) Without getting multiply defined linking e

How can I go about reusing the same kernel without getting fatal linking errors due to defining the symbol multiple times

In Visual Studio I get

“fatal error LNK1169: one or more multiply defined symbols found”

My current structure is as follows:
Interface.h has an extern interface to a C function: myCfunction() (ala the C++ integration SDK example)
Kernel.cu contains the actual global functions and is NOT included in the build: my_kernel()
Wrapper.cu inlcudes Kernel.cu and Interface.h and calls my_kernel<<<…>>>

This all works fine.

But if I add another C function in another file which also includes Kernel.cu and uses those kernels, I get the errors.

So how can I reuse the kernels in Kernel.cu among many C functions in different files.

The purpose of this by the way is unit testing, and integrating my kernels with CPP unit, if there is no way to reuse kernels (there must be!) then other suggestions for unit testing kernels within my existing CPP unit framework would be appreciate.

Thanks

Zenna

I do it like this:

MyFunction.cu:

  __global__ void MyFunctionKernel() {

	// kernel code

  }

void CallMyFunctionKernel() {

	MyFunctionKernel<<grid,block>>();

  }

MyFunction.h:

  extern void CallMyFunctionKernel();

Just link it in with your program. Whenever you want to run kernel from your C++ app, just include MyFunction.h and call the CallMyFunctionKernel function.