I am trying to perform FFT using the FFTW lib available for c++. Since there are many options for FFTW available i am trying to implement fft using the rfftwnd method(since my data is real).
#include<rfftw.h>
{
fftw_real a[width][2*(height/2+1)],b[width][2*(height/2+1)],c[width][height];
fftw_complex *A,*B,C[width][height/2+1];
rfftwnd_plan rp,rpin;
fftw_real scale = 1.0/(width*height);
const int H = height;
const int W= width;
rp = rfftw2d_create_plan(W,H,FFTW_REAL_TO_COMPLEX,FFTW_ESTIMATE);
rpin = rfftw2d_create_plan(width, height, FFTW_COMPLEX_TO_REAL,FFTW_ESTIMATE);
A = (fftw_complex*) &a[0][0];
B = (fftw_complex*) &b[0][0];
for(int i=0;i<width;i++)
{
for (int j=0;j<height;j++)
{
a[i][j] = la(i,j);
}
}
}
So i am basically trying to implement the fft on an image for this i need to create the plans as suggested in the FFTW documentation. But when i do this i get an errror saying
error: undefined reference to `rfftw2d_create_plan'
could someone please help as to why this is happening? Am i missing something here?
This is a linker error which tells you that the linker cannot find the indicated function, with the most likely reason being that the linker doesn't know about the librfftw.a
library which contains the definition (see this question & answers for more details, and more specifically this answer).
According to this section of FFTW documentation:
Programs using RFFTWND should be linked with -lrfftw -lfftw -lm on Unix systems, or with the FFTW, RFFTW, and standard math libraries in general.
So, you should be adding those required flags for compilation.