编译 CUDA 示例出现构建错误
我运行的是 Windows 7 64 位,带有 Visual Studio 2008。我安装了 CUDA 驱动程序和 SDK。 SDK 附带了很多示例,包括编译的可执行文件和源代码。编译后的可执行文件运行得非常好。当我打开 vc90 解决方案并在 Win32 配置中构建时,出现此错误:
Error 1 fatal error LNK1181: cannot open input file '.\Release\bandwidthTest.cu.obj' bandwidthTest bandwidthTest
构建日志:
1>------ Build started: Project: bandwidthTest, Configuration: Release Win32 ------
1>Compiling with CUDA Build Rule...
1>"C:\CUDA\bin64\nvcc.exe" -arch sm_10 -ccbin "c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin" -Xcompiler "/EHsc /W3 /nologo /O2 /Zi /MT " -I"C:\CUDA\include" -I"../../common/inc" -maxrregcount=32 --compile -o "Release\bandwidthTest.cu.obj" "c:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK\C\src\bandwidthTest\bandwidthTest.cu"
1>nvcc fatal : Visual Studio configuration file '(null)' could not be found for installation at 'c:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/bin/../..'
1>Linking...
1>LINK : fatal error LNK1181: cannot open input file '.\Release\bandwidthTest.cu.obj'
1>Build log was saved at "file://c:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK\C\src\bandwidthTest\Release\BuildLog.htm"
1>bandwidthTest - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
如果我尝试在 x64 中编译,它根本不会构建,只是跳过该项目
1>------ Skipped Build: Project: bandwidthTest ------
1>
========== Build: 0 succeeded or up-to-date, 0 failed, 1 skipped ==========
我是 C++ 新手,一直在做 C#一阵子。我确信我缺少一些小东西,但是您可以提供的任何线索将不胜感激。
I am running Windows 7 64bit, with Visual Studio 2008. I installed the CUDA drivers and SDK. The SDK comes with quite a few examples including compiled executables and source code. The compiled executables run wonderfully. When I open the vc90 solutions and go to build in Win32 configuration I get this error:
Error 1 fatal error LNK1181: cannot open input file '.\Release\bandwidthTest.cu.obj' bandwidthTest bandwidthTest
Build log:
1>------ Build started: Project: bandwidthTest, Configuration: Release Win32 ------
1>Compiling with CUDA Build Rule...
1>"C:\CUDA\bin64\nvcc.exe" -arch sm_10 -ccbin "c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin" -Xcompiler "/EHsc /W3 /nologo /O2 /Zi /MT " -I"C:\CUDA\include" -I"../../common/inc" -maxrregcount=32 --compile -o "Release\bandwidthTest.cu.obj" "c:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK\C\src\bandwidthTest\bandwidthTest.cu"
1>nvcc fatal : Visual Studio configuration file '(null)' could not be found for installation at 'c:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/bin/../..'
1>Linking...
1>LINK : fatal error LNK1181: cannot open input file '.\Release\bandwidthTest.cu.obj'
1>Build log was saved at "file://c:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK\C\src\bandwidthTest\Release\BuildLog.htm"
1>bandwidthTest - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
If I attempt to compile in x64 it doesn't build at all and just skips the project
1>------ Skipped Build: Project: bandwidthTest ------
1>
========== Build: 0 succeeded or up-to-date, 0 failed, 1 skipped ==========
I am new to C++, having been doing C# for a while. I'm certain there is something small that I am missing, but any clues you could provide would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
检查您是否安装了 x64 编译器。然后将项目类型更改为 x64。我在尝试用64位win7编译32位cuda程序时遇到了同样的问题。
另请确保您已将 64 位库添加到搜索路径中。
Check if you have x64 compiler installed. Then change project type to x64. I had the same problem when trying to compile 32bit cuda program with 64bit win7.
Also make sure you have added 64bit libs and includes to the search path.
您正在关注错误的错误消息。
.obj 文件不存在,因为 nvcc 编译步骤失败。
You're focusing on the wrong error message.
The .obj file doesn't exist because the nvcc compile step failed.
您需要确保所有工具都匹配。因此,如果您安装了 64 位 Visual Studio 编译器,那么您应该安装 64 位版本的 CUDA 工具包。
如果您只有 32 位 Visual Studio 编译器,那么您应该能够安装 32 位 CUDA 工具包。理想情况下,您应该安装所有 64 位工具。然后您将能够构建 64 位和 32 位(交叉编译)示例。
You need to make sure that all the tools match. So if you have the 64-bit Visual Studio compiler installed then you should install the 64-bit version of the CUDA toolkit.
If you only have the 32-bit Visual Studio compiler, then you should be able to install the 32-bit CUDA toolkit. Ideally you would install all the 64-bit tools. Then you will be able to build both the 64-bit and 32-bit (cross-compile) examples.