In addition to the previous CUDA posts, where you can learn how to install the required tools and make Visual C++ understand what you are using, you need to:
- Add the
NvCudaRuntimeApi.rules
to the project file (right click on the project, Custom Build Rules, tick the relevant box). - Add the CUDA runtime library (right click on the project and choose Properties, then in Linker -> General add
$(CUDA_PATH)\lib\$(PlatformName)
to the Additional Library Directories and in Linker -> Input addcudart.lib
to the Additional Dependencies). - Optionally add the CUDA include files to the search path, required
if you include any CUDA files in your .cpp files (as opposed to .cu
files) (right click on the project and choose Properties, then in C/C++ -> General add
$(CUDA_PATH)\include
to the Additional Include Directories). - Then just build your project and the .cu files will be compiled to .obj and added to the link automaticaly
- Change the code generation to use statically loaded C runtime to match the CUDA runtime; right click on the project and choose Properties, then in C/C++ -> Code Generation change the Runtime Library to /MT (or /MTd for debug, in which case you will need to mirror this in Runtime API -> Host -> Runtime Library). You might get error LNK4098 otherwise.
LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs
) or multiply defined symbols for standard library functions, then this should be your first suspect. Also, you might see LNK2001, LNK2005 when some conflict with the C++ runtime exists. A possible workaround might be using C functions.If you have Visual Studio 2010, here are the details for you:
http://stackoverflow.com/questions/3778799/how-do-i-start-a-cuda-app-in-visual-studio-2010/7285235#7285235
For older versions of CUDA:
http://stackoverflow.com/questions/2046228/how-do-i-start-a-new-cuda-project-in-visual-studio-2008
No comments:
Post a Comment