CUDA链接错误Visual Studio 2008

时间:2010-09-29 18:52:46

标签: c++ visual-studio cuda

您好我从CUDA src编译ConvolutionFFT2D时收到以下链接错误

1>------ Rebuild All started: Project: FinalTest, Configuration: Release Win32 ------

1>Deleting intermediate and output files for project 'FinalTest', configuration        
'Release|Win32'

1>Compiling with CUDA Build Rule...

1>"C:\CUDA\bin\nvcc.exe"    -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin"     -I"C:\CUDA\include" -I"./" -I"../../common/inc" -I"../../../shared/inc"  -Xcompiler "/EHsc /W3 /nologo /O2 /Zi   /MT  " -maxrregcount=32  -gencode=arch=compute_10,code=\"sm_10,compute_10\" -gencode=arch=compute_20,code=\"sm_20,compute_20\"  --compile -o "Release\convolutionFFT2D.cu.obj" "c:\Documents and Settings\All Users\Application Data\NVIDIA Corporation\NVIDIA GPU Computing SDK\C\src\convolutionFFT2D\convolutionFFT2D.cu" 

1>convolutionFFT2D.cu

1>tmpxft_00000a5c_00000000-6_convolutionFFT2D.compute_10.cudafe1.gpu

1>tmpxft_00000a5c_00000000-10_convolutionFFT2D.compute_10.cudafe2.gpu

1>convolutionFFT2D.cu

1>tmpxft_00000a5c_00000000-3_convolutionFFT2D.compute_20.cudafe1.gpu

1>tmpxft_00000a5c_00000000-14_convolutionFFT2D.compute_20.cudafe2.gpu

1>convolutionFFT2D.cu

1>tmpxft_00000a5c_00000000-6_convolutionFFT2D.compute_10.cudafe1.cpp

1>tmpxft_00000a5c_00000000-20_convolutionFFT2D.compute_10.ii

1>Compiling...

1>convolutionFFT2D_gold.cpp

1>main.cpp

1>Linking...

1>main.obj : error LNK2001: unresolved external symbol _cufftExecR2C@12

1>main.obj : error LNK2001: unresolved external symbol _cufftExecC2R@12

1>main.obj : error LNK2001: unresolved external symbol _cufftPlan2d@16

1>main.obj : error LNK2001: unresolved external symbol _cufftDestroy@4

1>C:\Documents and Settings\Administrator\My Documents\Visual Studio 
2008\Projects\FinalTest\Release\FinalTest.exe : fatal error LNK1120: 4 unresolved externals

1>Build log was saved at "file://c:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\FinalTest\FinalTest\Release\BuildLog.htm"

1>FinalTest - 5 error(s), 0 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

c / c ++ - >代码生成 - >运行时库在发布时设置为MT,在调试模式下设置为MTd。

任何输入?

编辑: 在链接器中添加cufft.lib->输入 - >附加依赖关系.....它会正常工作

2 个答案:

答案 0 :(得分:1)

在链接器中添加cufft.lib->输入 - >其他依赖关系.....它会正常工作

答案 1 :(得分:0)

在编辑解决方案时,您只需要将cufft.lib添加到其他依赖项中。由于您正在使用Visual Studio进行编译,因此您可能更喜欢使用pragma:

#pragma comment ( lib, "cufft.lib" )

然后您可以使用其他内容控制此操作,例如

#if USE_CUDA_FFT && (defined(WIN32) || defined(WIN64))

#pragma comment ( lib, "cufft.lib" )

#endif

我使用类似的开关来支持在Linux(使用gcc)和Windows(VS '05 / '08 / '10)中使用相同的源文件进行有条件的编译。