how to set up fftw for cygwin in Win XP

FFTW is essential for image processing, reconstruction, and other imaging related projects.
How to integrate FFTW into cygwin-Emacs-gcc programming chain:
1. instruction to follow: the INSTALL file in the package

2. 3 steps to build: ./configure, make, make install

3. the files will be placed into

4. test a cpp file:

#include <fftw/fftw3.h>
#include <iostream>
using namespace std;
int main()
cout << "fftw3.h is included" << endl;
fftw_complex *in, *out;
fftw_plan p;
int N = 64;//size of the fft
in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * N);
out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * N);
p = fftw_plan_dft_1d(N, in , out, FFTW_FORWARD, FFTW_ESTIMATE);
//now start initialize in
for(int i=0; i<N; i++)
in[i][0] = 1;
in[i][1] = 0;

fftw_execute(p);//actually run the fftw routine

for(int i=0; i<N; i++)
cout << "out[" << i << "] = " << out[i][0] << "+" << out[i][1] << "j" << endl;

5. write the makefile correctly:

CPP = g++
OFLAG = -Wall -o
LFLAG = -l
LIBDIR = /usr/local/lib/
INCLUDEDIR = /usr/local/include/
DEBUG = no

.SUFFIXES: .exe .cpp
$(CPP) $(OFLAG) $@ $<

main.exe: main.cpp
$(CPP) $(IFLAG) $(INCLUDEDIR) $(OFLAG) main.exe main.cpp $(LIBDIR)libfftw3.a

6. build

7. test the program main.exe


One thought on “how to set up fftw for cygwin in Win XP

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s