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
/usr/local/include
/usr/local/bin
/usr/local/lib

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;
}
fftw_destroy_plan(p);//
fftw_free(in);
fftw_free(out);
}

5. write the makefile correctly:

CPP = g++
OFLAG = -Wall -o
LFLAG = -l
IFLAG = -I
LIBFLAG = -L
LIBDIR = /usr/local/lib/
INCLUDEDIR = /usr/local/include/
DEBUGF = -g -D DEBUG
DEBUG = no

.SUFFIXES: .exe .cpp
.cpp.exe:
$(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

Advertisements

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:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s