views:

62

answers:

1

Hi I am getting the following Linking error while compiling ConvolutionFFT2D from CUDA src

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++ -> code generation -> runtime library is set to MT in release and MTd in Debug mode.

Any inputs ?

EDIT: Add cufft.lib in Linker->Input->Additional Dependencies ..... And it will work fine

A: 

As your solution was edited, you simply need to add cufft.lib to your additional dependencies. Since you're compiling with Visual studio, you might prefer to use the pragma:

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

You can then control this with other things like

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

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

#endif

I use similar switches like this to support compiling conditionally in Linux (with gcc) as well as in Windows (VS '05 / '08 / '10) using the same source files.

M. Tibbits