VC++ 2008 Express 下CUDA编译

以前都是用自定义编译方式编译cu文件,今天装上CUDA2.2发现已经提供了生成规则,太方便了,再也不用拷贝编译命令行了。方法如下:

将CUDA SDK目录下common目录中的cuda.rules拷贝到%VS9.0%\VC\VCProjectDefaults下,右键点击项目,选择【自定义生成规则】,在CUDA**前打勾即可,相当方便啊。

 

另外顺便提一下如何让IDE识别CU文件:

1、首先在【工具】->【选项】->【项目和解决方案】->【VC++项目设置】中,C/C++文件扩展名中添加.cu,包含文件中添加.cuh。

2、 在【工具】->【选项】->【项目和解决方案】->【文本编辑器】->【文件扩展名】中添加cu和cuh。

3、重启VS。

4、可能会发现 对于cu文件无法显示导航栏,可以通过添加如下注册表项解决:

 Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.cu]
@="VCExpress.cu.9.0"
"Content Type"="text/plain"
"PerceivedType"="text"

[HKEY_CLASSES_ROOT\.cu\OpenWithProgids]
"VCExpress.cpp.9.0"=""

[HKEY_CLASSES_ROOT\.cu\OpenWithProgids\Shared]
@="Shared key to keep this from being removed with install/uninstall of side-by-side components."

[HKEY_CLASSES_ROOT\.cu\PersistentHandler]
@="{5e941d80-bf96-11cd-b579-08002b30bfeb}"

 [HKEY_CLASSES_ROOT\.cuh]
@="VCExpress.cuh.9.0"
"Content Type"="text/plain"
"PerceivedType"="text"

[HKEY_CLASSES_ROOT\.cuh\OpenWithProgids]
"VCExpress.cpp.9.0"=""

[HKEY_CLASSES_ROOT\.cuh\OpenWithProgids\Shared]
@="Shared key to keep this from being removed with install/uninstall of side-by-side components."

[HKEY_CLASSES_ROOT\.cuh\PersistentHandler]
@="{5e941d80-bf96-11cd-b579-08002b30bfeb}"

 [HKEY_CLASSES_ROOT\VCExpress.cu.9.0]
@="C++ Source"

[HKEY_CLASSES_ROOT\VCExpress.cu.9.0\DefaultIcon]
@="C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\vcpackages\\VCProject.dll,2"

[HKEY_CLASSES_ROOT\VCExpress.cu.9.0\shell]

[HKEY_CLASSES_ROOT\VCExpress.cu.9.0\shell\Open]

[HKEY_CLASSES_ROOT\VCExpress.cu.9.0\shell\Open\Command]
@="\"C:\\Program Files\\Microsoft Visual Studio 9.0\\Common7\\IDE\\VCExpress.exe\" /dde"

[HKEY_CLASSES_ROOT\VCExpress.cu.9.0\shell\Open\ddeexec]
@="Open(\"%1\")"

[HKEY_CLASSES_ROOT\VCExpress.cu.9.0\shell\Open\ddeexec\Application]
@="VCExpress.9.0"

[HKEY_CLASSES_ROOT\VCExpress.cu.9.0\shell\Open\ddeexec\Topic]
@="system"
[HKEY_CLASSES_ROOT\VCExpress.cuh.9.0]

[HKEY_CLASSES_ROOT\VCExpress.cuh.9.0\DefaultIcon]
@="C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\vcpackages\\VCProject.dll,4"

[HKEY_CLASSES_ROOT\VCExpress.cuh.9.0\shell]

[HKEY_CLASSES_ROOT\VCExpress.cuh.9.0\shell\Open]

[HKEY_CLASSES_ROOT\VCExpress.cuh.9.0\shell\Open\Command]
@="\"C:\\Program Files\\Microsoft Visual Studio 9.0\\Common7\\IDE\\VCExpress.exe\" /dde"

[HKEY_CLASSES_ROOT\VCExpress.cuh.9.0\shell\Open\ddeexec]
@="Open(\"%1\")"

[HKEY_CLASSES_ROOT\VCExpress.cuh.9.0\shell\Open\ddeexec\Application]
@="VCExpress.9.0"

[HKEY_CLASSES_ROOT\VCExpress.cuh.9.0\shell\Open\ddeexec\Topic]
@="system"

posted on 2009-06-18 10:05  codezhang  阅读(1245)  评论(0编辑  收藏  举报

导航