A common scenario where functions from CUDA code remain unresolved during linking is when CUDA code is called from plain C code. The CUDA compiler uses a C++ frontend, causing functions names to be decorated in the generated object code, whereas the object files for the calling C code contain the undecorated name (this is a generic issue in mixed C/C++ programming not specific to CUDA). To address this mismctahc one could compile the calling code as C++ code instead of C code, but more commonly one would instruct the CUDA compiler to leave the function name undecorated by use of an
I did try add extern “C” in various combination, It still doesn’t work.
The strange thing is I tried in VS2008 and CUDA 4.0 RC1, it works.
Is that possible is that because cuda4.0 RC1 doesn’t have good support in VS2010
I am using 64 bit environment
I list what I did, hope someone could help me out(Also, I attached the code). Currently I need to integrate a CUDA code library in to an existing codebase. I couldn’t move forward because of this. It is really driving me crazy…
Inside this interface class, there is a interface function called CUDALIB::Interface(), It will call functionalities inside *.cu files.
Inside cudaKernel.cu, there is a simple function
The Link error is:
1>CUDALIB.obj : error LNK2019: unresolved external symbol CUDAKernel referenced in function “public: void __cdecl CUDALIB::Interface(void)” (?Interface@CUDALIB@@QEAAXXZ)
since I don’t have 4.0 installed, I could not open your project, BUT from your NVCC command line i believe as I suspected that you are not compiling into a hybrid object (–compile or -c). so what might be happening is that that you are compiling your CU file into a cubin and not linking your main to it.
Try selecting “generate hybrid object” in your “NVCC compilation type” field in the cuda build rule.
Alternatively you could explicitly link to the created cuda binary.