Linking Problem in Visual Studio 2005 linking failed when int main() in .cpp

Hi friends,

I’m new to CUDA, and there is a problem I face.

I always failed linking a program with int main() placed in .cpp file, but if I moved int main() to .cu file, the linking has no problem.

Currently I’m using Jared’s custom build rule.

It seemed strange to me. Is there anyone can explain?

I would suggest that you take a look at the cppIntegration SDK sample to see how to compile and link together .cu files with .cpp files.

Dear Cyril,

It works, thank you very much. I didn’t know that example projects contain many helpful things. If I can draw some conclusions, best practices are:

  1. Kernels are typed like .h files, but in .cu files

  2. Kernel stubs are typed like .cpp files, but in .cu files

  3. Kernel stubs must be preceded by extern “C”

Am I right?