CUDA and C++ linking problems


I’m developing a CUDA library with the biggest part written in C++. To test this library I have created a second project that uses this CUDA library. The library project compiles correctly, but as soon as I want to use it within the console test application I get a linker error that a function is not found.

I’m using Microsoft Visual C++ 2008 Express Edition with the CUDA Wizard installed.

The error:

error LNK2019: unresolved external symbol _smithwatermancuda referenced in function "public: void __thiscall SmithWatermanCUDA::run(void)" (?run@SmithWatermanCUDA@@QAEXXZ)

The library (so far) is basicly one class which calls a CUDA kernel from the run() function.

Some code snippets from the library project:


#include "smithwatermancuda.h"

extern "C" void smithwatermancuda();

void SmithWatermanCUDA::run()




#include ""

extern "C" void smithwatermancuda()


	dim3 grid(1, 1, 1);

	dim3 threads(10, 1, 1);

	smithwatermancuda_kernel<<< grid, threads >>>();




__global__ void smithwatermancuda_kernel()




So the library project builds correctly, but as soon as being used in a different application the linker error occurs.

I’ve attached the whole solution to this post.

Hopefuly somebody could explain what goes wrong.


CUDA_C___Test.rar (9.9 KB)

Ok, I managed to get it working.
It seems that is never compiled by nvcc. If I rename it to something else, it works fine. If this is a bug or if the filename (without extension) can’t be the same as a .cpp file I do not know.

So what I basically have is:
smithwaterman.h (class definition)
smithwaterman.cpp (class implemention) (external “C” function) (the actual cuda kernel)

the didn’t get compiled, but after renaming it, it works fine.

Probably both and smithwaterman.cpp were being compiled to smithwaterman.obj.