I am not able to link fftw3 library with my c program c code: #include<stdio.h> #include<fftw3.h> int main() { int i=0; fftw_complex *in,*out; fftw_plan p; fftw_malloc ; int N=100; in=(fft_complex*)fft_malloc(sizeof(fftw_complex) * N); out=(fft_complex*)fft_malloc(sizeof(fftw_complex) * N); for(i=0;i <N;i++) *(in+i)=i; p = fftw_plan_dft_r2c_1d(N, in, out,FFT_PRESERVE_INPUT); fftw_execute(p); fftw_destroy_plan(p); fftw_free(in); fftw_free(out); for(i=0;i<N;i++) printf("%d \n",out[i]); return(0); } gcc -lfftw3 -o fft fft.c -L/usr/local/lib output fft.c: In function ‘main’: fft.c:15: error: ‘fft_complex’ undeclared (first use in this function) fft.c:15: error: (Each undeclared identifier is reported only once fft.c:15: error: for each function it appears in.) fft.c:15: error: expected expression before ‘)’ token fft.c:16: error: expected expression before ‘)’ token fft.c:18: error: incompatible types in assignment fft.c:19: error: ‘FFT_PRESERVE_INPUT’ undeclared (first use in this function) fft.c:19: warning: passing argument 2 of ‘fftw_plan_dft_r2c_1d’ from incompatible pointer type CXan anyone help me out
error in linking fftw
Started by ●June 4, 2009
Reply by ●June 8, 20092009-06-08
mayur.sarode wrote:> I am not able to link fftw3 library with my c program > c code: > > #include<stdio.h> > #include<fftw3.h> > int main() > { > int i=0; > fftw_complex *in,*out; > fftw_plan p; > fftw_malloc ; > int N=100; > in=(fft_complex*)fft_malloc(sizeof(fftw_complex) * N); > out=(fft_complex*)fft_malloc(sizeof(fftw_complex) * N); > for(i=0;i <N;i++) > *(in+i)=i; > p = fftw_plan_dft_r2c_1d(N, in, out,FFT_PRESERVE_INPUT); > fftw_execute(p); > fftw_destroy_plan(p); > fftw_free(in); > fftw_free(out); > for(i=0;i<N;i++) > printf("%d \n",out[i]); > return(0); > } > > gcc -lfftw3 -o fft fft.c -L/usr/local/lib > > > output > fft.c: In function ‘main’: > fft.c:15: error: ‘fft_complex’ undeclared (first use in this > function) > fft.c:15: error: (Each undeclared identifier is reported only once > fft.c:15: error: for each function it appears in.) > fft.c:15: error: expected expression before ‘)’ token > fft.c:16: error: expected expression before ‘)’ token > fft.c:18: error: incompatible types in assignment > fft.c:19: error: ‘FFT_PRESERVE_INPUT’ undeclared (first use in this > function) > fft.c:19: warning: passing argument 2 of ‘fftw_plan_dft_r2c_1d’ from > incompatible pointer type > > CXan anyone help me out > > >gcc -lfftw3 -o fft fft.c -I/usr/local/include -L/usr/local/lib Paul
Reply by ●June 8, 20092009-06-08
Paul Russell wrote:> mayur.sarode wrote: >> I am not able to link fftw3 library with my c program >> c code: >> >> #include<stdio.h> >> #include<fftw3.h> >> int main() >> { >> int i=0; >> fftw_complex *in,*out; >> fftw_plan p; >> fftw_malloc ; >> int N=100; >> in=(fft_complex*)fft_malloc(sizeof(fftw_complex) * N); >> out=(fft_complex*)fft_malloc(sizeof(fftw_complex) * N); >> for(i=0;i <N;i++) >> *(in+i)=i; >> p = fftw_plan_dft_r2c_1d(N, in, out,FFT_PRESERVE_INPUT); >> fftw_execute(p); >> fftw_destroy_plan(p); >> fftw_free(in); >> fftw_free(out); >> for(i=0;i<N;i++) >> printf("%d \n",out[i]); >> return(0); >> } >> >> gcc -lfftw3 -o fft fft.c -L/usr/local/lib >> >> >> output >> fft.c: In function ‘main’: >> fft.c:15: error: ‘fft_complex’ undeclared (first use in this >> function) >> fft.c:15: error: (Each undeclared identifier is reported only once >> fft.c:15: error: for each function it appears in.) >> fft.c:15: error: expected expression before ‘)’ token >> fft.c:16: error: expected expression before ‘)’ token >> fft.c:18: error: incompatible types in assignment >> fft.c:19: error: ‘FFT_PRESERVE_INPUT’ undeclared (first use in this >> function) >> fft.c:19: warning: passing argument 2 of ‘fftw_plan_dft_r2c_1d’ from >> incompatible pointer type >> >> CXan anyone help me out >> >> >> > > gcc -lfftw3 -o fft fft.c -I/usr/local/include -L/usr/local/lib > > PaulAlso note that there are numerous typos, e.g. it should be "fftw_malloc", "fftw_complex" and "FFTW_PRESERVE_INPUT". Paul