cufft LNK2019 error

Hello all,

I am running a very basic cufft program (from Nvidia website) just to get to grips with it…

#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <cufft.h>
#include <stdio.h>

int main()
{
#define NX 256
#define BATCH 10
	cufftHandle plan;
	cufftComplex *data;
	cudaMalloc((void**)&data, sizeof(cufftComplex)*(NX / 2 + 1)*BATCH);
	/* Create a 1D FFT plan. */
	cufftPlan1d(&plan, NX, CUFFT_R2C, BATCH);
	/* Use the CUFFT plan to transform the signal in place. */
	cufftExecR2C(plan, (cufftReal*)data, data);
	/* Destroy the CUFFT plan. */
	cufftDestroy(plan);
	cudaFree(data);
	return 0;
}

I have added the “cufft.lib” to additional libraries in the linker, added the directory and changed the architecture to x64. However, i still get…

Error 1 error LNK2019: unresolved external symbol cufftPlan1d referenced in function main
Error 2 error LNK2019: unresolved external symbol cufftExecR2C referenced in function main
Error 3 error LNK2019: unresolved external symbol cufftDestroy referenced in function main
Error 4 error LNK1120: 3 unresolved externals

How can I fix this?

Thanks

hese are link errors not compilation errors, so they have nothing to do with cufft.h.

what you are probably missing is the cufft.lib in your linker input. (in VS: Project Properties->Linker->Input->Additional Dependencies)

1 Like

I got similar problems today. I would suggest to copy the folder “simpleCUFFT” from the directory:

C:\ProgramData\NVIDIA Corporation\CUDA Samples\v7.5\7_CUDALibraries\simpleCUFFT
(Your directory may be different)

to your target location and then change it to your needs.

In VS2013 → Project → Properties → VC++ Directories → Include Directories

Add:

C:\ProgramData\NVIDIA Corporation\CUDA Samples\v7.5\common\inc
(Your directory may be different)

In VS2013 → Project → Properties → CUDA C/C++ → Common → Additional Include Directories

Add:

./;C:\ProgramData\NVIDIA Corporation\CUDA Samples\v7.5\common\inc
(Your directory may be different)

This worked for me