Linking error building simple application using CUDA driver API driver, linking error

Good morning,

I’m doing a very dummy exercise trying to rewrite he vectorAddDrv project from scratch to undrstand the basic problems. I have win7 64bit and I have installed the proper packages, in general the examples work and I can in example rebuild the vectorAddDrv project. I’m using VC2008 express.

The new project is generated from scratch, using the empty project template. Is composed by just two files: main.cpp and cuda_kernels.cu.

I’ve added the Cuda.rules file to build the cuda files and in general I think I’ve all the main property that are in the vectorAddDrv project. The main difference, that I think is connected to the problem appears during the compilation step: vectorAddDrv compiles the .cu files twice with the following messages:

1>Compiling with CUDA Build Rule...

1>"C:\CUDA\bin64\nvcc.exe"   -m32 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin"  -D_DEBUG -D_WIN32   -I"C:\CUDA\include" -I"./" -I"../../common/inc" -I"../../../shared/inc"  -Xcompiler "/EHsc /W3 /nologo /Od /Zi   /MT  " -maxrregcount=32 --ptxas-options=-v -gencode=arch=compute_10,code=\"sm_10,compute_10\"   -ptx -o "data\vectorAdd.ptx" "c:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK\C\src\vectorAddDrv\vectorAdd.cu" 

1>vectorAdd.cu

1>tmpxft_000014ac_00000000-3_vectorAdd.cudafe1.gpu

1>tmpxft_000014ac_00000000-8_vectorAdd.cudafe2.gpu

1>Compiling...

1>vectorAdd.cpp

1>Linking...

the linking step continues without errors. In my project instead I see:

1>Compiling with CUDA Build Rule...

1>"C:\CUDA\bin64\nvcc.exe"   -m32 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin"	 -I"C:\CUDA\include" -I"./" -I"../../common/inc" -I"../../../shared/inc"  -Xcompiler "/EHsc /W3 /nologo /O2 /Zi   /MT  " -maxrregcount=32  -gencode=arch=compute_10,code=\"sm_10,compute_10\" -gencode=arch=compute_20,code=\"sm_20,compute_20\"  --compile -o "Debug\cuda_kernels.cu.obj" "c:\Users\volpig\Documents\Visual Studio 2008\Projects\cudaProva2\cudaProva2\cuda_kernels.cu" 

1>cuda_kernels.cu

1>tmpxft_00003220_00000000-6_cuda_kernels.compute_10.cudafe1.gpu

1>tmpxft_00003220_00000000-10_cuda_kernels.compute_10.cudafe2.gpu

1>cuda_kernels.cu

1>tmpxft_00003220_00000000-3_cuda_kernels.compute_20.cudafe1.gpu

1>tmpxft_00003220_00000000-14_cuda_kernels.compute_20.cudafe2.gpu

1>cuda_kernels.cu

1>tmpxft_00003220_00000000-6_cuda_kernels.compute_10.cudafe1.cpp

1>tmpxft_00003220_00000000-20_cuda_kernels.compute_10.ii

1>Compiling...

1>main.cpp

1>Compiling manifest to resources...

1>Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1

1>Copyright (C) Microsoft Corporation.  All rights reserved.

1>Linking...

1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library

1>cuda_kernels.cu.obj : error LNK2019: unresolved external symbol ___cudaUnregisterFatBinary@4 referenced in function "void __cdecl __cudaUnregisterBinaryUtil(void)" (?__cudaUnregisterBinaryUtil@@YAXXZ)

1>cuda_kernels.cu.obj : error LNK2019: unresolved external symbol _cudaLaunch@4 referenced in function "enum cudaError __cdecl cudaLaunch<char>(char *)" (??$cudaLaunch@D@@YA?AW4cudaError@@PAD@Z)

1>cuda_kernels.cu.obj : error LNK2019: unresolved external symbol _cudaSetupArgument@12 referenced in function "void __cdecl __device_stub__Z10kernel_addPKfS0_Pfi(float const *,float const *,float *,int)" (?__device_stub__Z10kernel_addPKfS0_Pfi@@YAXPBM0PAMH@Z)

1>cuda_kernels.cu.obj : error LNK2019: unresolved external symbol ___cudaRegisterFunction@40 referenced in function "void __cdecl __sti____cudaRegisterAll_58_tmpxft_00003220_00000000_8_cuda_

kernels_compute_10_cpp1_ii_7c4b43eb(void)" (?__sti____cudaRegisterAll_58_tmpxft_00003220_00000000_8_cuda_

kernels_compute_10_cpp1_ii_7c4b43eb@@YAXXZ)

1>cuda_kernels.cu.obj : error LNK2019: unresolved external symbol ___cudaRegisterFatBinary@4 referenced in function "void __cdecl __sti____cudaRegisterAll_58_tmpxft_00003220_00000000_8_cuda_

kernels_compute_10_cpp1_ii_7c4b43eb(void)" (?__sti____cudaRegisterAll_58_tmpxft_00003220_00000000_8_cuda_

kernels_compute_10_cpp1_ii_7c4b43eb@@YAXXZ)

and the linking fails. While cuda here compiles the .cu source three times? while is the linker asking for runtime libraries?

thanks for any help.