CUDA's enviroment build and configuration in VC2008
This article is a CUDA config and enviroment build in VC2008, VC2005 should also OK.
1,default location and order install this three tool:
devdriver_3.0_winxp_32_197.13_general.exe
cudatoolkit_3.0_win_32.exe
gpucomputingsdk_3.0_win_32.exe
2,Test the cuda tool
C:/Documents and Settings/All Users/Application Data/NVIDIA Corporation/NVIDIA GPU Computing SDK/C/bin/win32/Release/
double click and run the release version's CUDA programs, Such as "deviceQuery.exe"; If CUDA install OK it will show run result,it means that eveything has been installed OK.
3,copy the CUDA default rule file which is configed OK original.
C:/Documents and Settings/All Users/Application Data/NVIDIA Corporation/NVIDIA GPU Computing SDK/C/common/Cuda.rules
to
C:/Program Files/Microsoft Visual Studio 9.0/VC/VCProjectDefaults/
4,copy the path of
C:/Documents and Settings/All Users/Application Data/NVIDIA Corporation/NVIDIA GPU Computing SDK/C/common/
C:/Documents and Settings/All Users/Application Data/NVIDIA Corporation/NVIDIA GPU Computing SDK/shared/
C:/Documents and Settings/All Users/Application Data/NVIDIA Corporation/NVIDIA GPU Computing SDK/OpenCL
C:/CUDA/
the three folders: inc(include)lib(library) src(source)'s location to
VC Tools--Options--Project and Solutions--VC++ Directories
relate config path of the inc(include)lib(library) src(source).then config the path
"C:/CUDA/bin/" to "Executable files"
For Highlight code as cpp file, Please also copy
C:/Documents and Settings/All Users/Application Data/NVIDIA Corporation/NVIDIA GPU Computing SDK/C/doc/syntax_highlighting/visual_studio_8/usertype.dat
to
C:/Program Files/Microsoft Visual Studio 8/VC/VCProjectDefaults/
also in VC++ Project Settings:C/C++ File extensions:add *.cu, in "Text editor-File extension":add cu relate editor to "Microsoft VC++ editor";
5,Restart the VC and then build a null project,such as "CUDAtest" add the "cu" source file into the project and then copy and paste the demo code into it, or you can use the following test code(a little code for OpenGL):
6,The most important item:
save then you need config the "CUDAtest"--"Custom Build Rules"(right click),you can see the CUDA Build Rule showed int the "Availble Rule Files", select and then OK.
config the "CUDAtest" property's "Configuration Properties"--"Linker"--"Input"--"Additional Dependencies"--"cudart.lib cutil32D.lib"(not include ").this step is for the normal link issues that cause by the important lib, it always show the link error just like following show:
1>------ Build started: Project: cudatest, Configuration: Debug Win32 ------
1>Linking...
1>cudatest.cu.obj : error LNK2019: unresolved external symbol ___cudaUnregisterFatBinary@4 referenced in function "void __cdecl __cudaUnregisterBinaryUtil(void)" (?__cudaUnregisterBinaryUtil@@YAXXZ)
...
1>cudatest.cu.obj : error LNK2019: unresolved external symbol _cudaMalloc@8 referenced in function _main
1>C:/HOME/Evel/CUDA/cudatest/Debug/cudatest.exe : fatal error LNK1120: 9 unresolved externals
1>Build log was saved at "file://c:/HOME/Evel/CUDA/cudatest/cudatest/Debug/BuildLog.htm"
1>cudatest - 10 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
if the project need include extra include files, then config the rules: "CUDA Build Rule v3.0"--"Additional Include Directories"--"C:/CUDA/include1; D:/CUDA/include2".
OK! now it's time to test the first CUDA code:
"Build Solution"(F7)--"Strat Without Debugging"(Ctrl+F5)
7,If no other issues, every thing should be OK and then show the run result.
For the code more fast, use Visual Assist to achieve auto finished function as c++ code, Please make sure close the IDE first and then
follow this address step:
http://blog.csdn.net/OpenHero/archive/2008/04/24/2324711.aspx
Notice: if the inc(include) path has been config OK, when you open VC the second time, it will be OK in Visual Assist's include path, so you can ignore the Visual Assist's include file config step.