add other projects at CUDA solution(VS2005)

i’m new at CUDA.
i wonder how other projects add to CUDA solution at VS2005,
i thought simple that just revise properties of projects after include solution,
but it didn’t work with number of errors,

anybody help me, plz,

anyway, is it possible???

My friend, probably you have a Linkage problem !! Can you display the error here, and hopefully a solution to your problem will be posted back !! :mellow:

Yeah, you’re right, all of my error is involved in linking,

This is my error,

LIBCMTD.lib(crt0.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup.

I tried many different ways for C/C++ debugging(about linking),

No matter how many try, it was no use,

So sad,T.T

Help me, please

Up

I have the exact same problem. I had a previous C++ solution, and I added my CUDA solution (composed of the kernel (kernel.cu), plus a fonction that allocates memory on the device and launches the kernel (launch_kernel.cu), and a header file (header_kernel.h) containing the prototype of launch_kernel(), as well as the libraries needed (cuda_runtime.h, cutil.h etc)… This header is included in both kernel.cu and launch_kernel.cu files.

I paid attention to include the additional include directories (C:/CUDA/INCLUDE etc…) in Properties>Configuration Properties>C/C++>General>Additional Include Directories( so that the main program have access to the *.h needed)

But when I build the solution under VS2005, i get a lot of error messages LNK 2019, all related to unresolved external symbol concerning Cuda fonction, such as error

LNK2019: unresolved external symbol _cudaThreadSynchronize@0 referenced in function "void __cdecl runBF(float *,unsigned short *,int,int,int)" (?runBF@@YAXPAMPAGHHH@Z)

The function runBF is the function defined in launchkernel.cu, it is the one that is used to launch the entire CUDA program. It’s therefore using lots of different CUDA functions.

I’ve tried to change the definition of the function ( void runBF (…) ) in launch_kernel.cu by extern “C” void runBF (…), but it didn’t solve anything.

I’m quite new to CUDA, and really clueless concerning this issue. I’d really appreciate if someone could help me on that.

Thx, Tom

6>essai1.lib(BF.obj) : error LNK2019: unresolved external symbol _cudaThreadExit@0 referenced in function _runBF

6>essai1.lib(BF.obj) : error LNK2019: unresolved external symbol _cudaFree@4 referenced in function _runBF

6>essai1.lib(BF.obj) : error LNK2019: unresolved external symbol _cudaThreadSynchronize@0 referenced in function _runBF

6>essai1.lib(BF.obj) : error LNK2019: unresolved external symbol _cudaConfigureCall@32 referenced in function _runBF

6>essai1.lib(BF.obj) : error LNK2019: unresolved external symbol _cudaMemcpy3D@4 referenced in function _runBF

6>essai1.lib(BF.obj) : error LNK2019: unresolved external symbol _cudaMemset3D@32 referenced in function _runBF

6>essai1.lib(BF.obj) : error LNK2019: unresolved external symbol _cudaMalloc3D@16 referenced in function _runBF

6>essai1.lib(BF.obj) : error LNK2019: unresolved external symbol _cudaGetErrorString@4 referenced in function _runBF

6>essai1.lib(BF.obj) : error LNK2019: unresolved external symbol _cudaGetLastError@0 referenced in function _runBF

6>essai1.lib(BF.obj) : error LNK2019: unresolved external symbol _cudaMemcpy2D@28 referenced in function _runBF

6>essai1.lib(BF.obj) : error LNK2019: unresolved external symbol _cudaMallocPitch@16 referenced in function _runBF

6>essai1.lib(BF.obj) : error LNK2019: unresolved external symbol _cudaSetupArgument@12 referenced in function ___device_stub__Z8KernelBFPfjPtjS_jjj

6>essai1.lib(BF.obj) : error LNK2019: unresolved external symbol ___cudaRegisterVar@32 referenced in function ___sti____cudaRegisterAll_37_tmpxft_000004f0_00000000_6_BF_c

pp1_ii_c14de7b3

6>essai1.lib(BF.obj) : error LNK2019: unresolved external symbol ___cudaRegisterFunction@40 referenced in function ___sti____cudaRegisterAll_37_tmpxft_000004f0_00000000_6_BF_c

pp1_ii_c14de7b3

6>essai1.lib(BF.obj) : error LNK2019: unresolved external symbol ___cudaRegisterFatBinary@4 referenced in function ___sti____cudaRegisterAll_37_tmpxft_000004f0_00000000_6_BF_c

pp1_ii_c14de7b3

6>essai1.lib(BF.obj) : error LNK2019: unresolved external symbol ___cudaUnregisterFatBinary@4 referenced in function ___cudaUnregisterBinaryUtil

6>essai1.lib(BF.obj) : error LNK2019: unresolved external symbol _cudaMemcpyToSymbol@20 referenced in function "enum cudaError __cdecl cudaMemcpyToSymbol<float [9]>(float const (&)[9],void const *,unsigned int,unsigned int,enum cudaMemcpyKind)" (??$cudaMemcpyToSymbol@$$BY08M@@YA?AW4cudaError@@AAY08$$CBMPBXIIW4cudaMemcpyKind@@@Z)

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

Here is the full detail of my build log… if anyone was asking for it !

I finally found the solution to my pb. It was actually a library pb.
When adding a CUDA project to a previously existing C/C++ project in VS 2005 you have to define the libraries at stake (here it was cudart.lib and cutil32.lib) (Project Properties>Linker>Input>Additionnal dependencies). An you also have to indicate the directories in which they are located (Linker>General>Additional directories).

Now everything works just fine ! Hope this thread could be helpful to others encountering the same issue. ^_^

Tom.

Thank you for your solution, but I had already tried the thing what you said,
in my case, I knew the thing you said,
so I gave up and started new solution, and now I have LINK ERRORS between .cu and .c(not .cpp)
it makes me so stressful,
The object of .cu doesn’t find functions at .c files,
What can I do for this error???

Since i do not know the kind of link error that you have I would recommend the following.

-> If you are adding your CUDA project to an existing project, configure it so that it is compiled as a static library

-> Declare the function that lauches as extern above the main (the extern “C” declaration should also be added before the definition of the function).

-> Then in the project properties add

   in Linker>Input cudart.lib and cutil32.lib (or cutil32D.lib) depending on whether you are using the release or debug mode

   in Linker>General add the paths to the library (cutil32 and cudart), in my case it is located in both C:\CUDA\lib and in my documents&settings\...\common\inc

   in C/C++>general>additional include directories:  "$(NVSDKCUDA_ROOT)\common\inc";"$(CUDA_INC_PATH)"

This is everything i’ve done (i think so… :wacko: ), and it is working.