You are on page 1of 6

FFTW Installation on Windows

http://www.fftw.org/install/windows.html#fftw2

Go back to the FFTW download page.

Windows Installation Notes


This document contains various information regarding installation of FFTW on DOS/Windows. (It was sent in by users, and has not been personally verified by us.) Please contact us if you have any additions or corrections. You should, of course, first read the Installation on non-Unix Systems of the FFTW 3 manual (or the corresponding section of the FFTW 2 manual).

Precompiled FFTW 3.2.2 Windows DLLs


We have created precompiled DLL files for FFTW 3.2.2 in single/double/long-double precision, along with the associated test programs. We hope that these are sufficient for most users, so that you need not worry about compiling FFTW: 32-bit version: fftw-3.2.2.pl1-dll32.zip (1.8MB) 64-bit version: fftw-3.2.2-dll64.zip (2.2MB) These DLLs were created by us, cross-compiled from GNU/Linux using MinGW; the 64-bit version is possible thanks to the mingw-w64 project. You should be able to call them from any compiler. In order to link to them from Visual C++, you will need to create .lib "import libraries" using the lib.exe program included with VC++. Run:
lib /def:libfftw3-3.def lib /def:libfftw3f-3.def lib /def:libfftw3l-3.def

For Borland C++, you instead need to use Borland's implib program, via (thanks to M. Lenarczyk):
implib -a fftw3-3.lib libfftw3-3.dll implib -a fftw3f-3.lib libfftw3f-3.dll implib -a fftw3l-3.lib libfftw3l-3.dll

See DLLs and wisdom, below, for important information on using wisdom import/export from a DLL. Contact us if you have suggestions, but realize that we don't use Windows ourselves. We created these .zip files with the scripts BUILD-MINGW32.sh and BUILD-MINGW64.sh; see also the MinGW instructions below. Thanks to John Pavel for his extensive feedback.

Compiling FFTW 3 for Windows


If for some reason you need to compile FFTW yourself on Windows, rather than using the above DLLs, you have several options: MinGW: this is a free Unix-like environment for Windows based on the GNU C compiler (gcc). We recommend this route because it produces native Windows executables/libraries, but lets you use our standard Unix build scripts and Makefiles, automatically picks good compiler flags, and so on. See below for instructions. Visual C++: In the past, several users have contributed Visual C++ project files for FFTW which you can download below. However, most versions of VC++ generate incorrect code for FFTW when SSE/SSE2 is enabled. VC++ 2003 definitely fails. VC++ 2005 may work. Intel C: you can also use the Intel compilers under VC++ (see below). This may produce marginally faster code than the GNU C compiler, but is probably not worth it for most users. Be cautious with the compiler flagsturning on every optimization under the sun usually makes FFTW slower. If you do compile FFTW yourself, we encourage you to compare the speed of the resulting executable with

1 de 6

15/08/2009 06:00 p.m.

FFTW Installation on Windows

http://www.fftw.org/install/windows.html#fftw2

the gcc-compiled version that we provide above. In particular, you can use the bench.exe program to benchmark a few typical sizes to get an idea of how they compare:
bench.exe -opatient 64 128 256 512 1024 2048 4096

Building FFTW 3 under MinGW


The simplest way to compile FFTW on Windows is probably to install the free MinGW Unix environment so that you can use the GNU C compiler (gcc). There are a few options to our configure script that we especially recommend on Windows: 2009), the alloca function seems to be broken under the 64-bit MinGW compilers, so when compiling for Win64 you should pass --disable-alloca to tell FFTW not to use that function --with-our-malloc16: this is required in order to allocate properly aligned memory (for SSE) with gcc --with-windows-f77-mangling: this will include Fortran wrappers for some common Windows Fortran compilers (GNU, Intel, and Digital). --enable-shared --disable-static: this will create DLLs instead of static libraries (since MinGW's static-library format seems to be different from Microsoft's). --enable-threads --with-combined-threads: this will include multi-threading support. The second option puts the multi-threading functions into the main FFTW DLL rather than into a separate DLL (the default under Unix); this is required because MinGW can't create DLLs that depend on one another. --enable-portable-binary: required if you want to create DLLs that will work on any Intel processor. One of the following two to exploit SSE/SSE2 (the DLL is still portable because it checks at runtime to make sure SSE/SSE2 is available): --enable-sse2: if you are creating a double-precision library, you should use our SSE2 support --enable-float --enable-sse: if you are creating a single-precision library, you should use our SSE support So, for example, to build a double-precision library you might use
./configure --with-our-malloc16 --with-windows-f77-mangling --enable-shared --disable-sta make make install --disable-alloca: as of this writing (14 July

The resulting DLL files are installed in /usr/local/bin. Important: If you want to call the resulting DLL from another compiler (i.e. not from MinGW), you need to add a line #define FFTW_DLL to fftw3.h (installed in /usr/local/include). This adds some __declspec decorations to the function declarations.

Building FFTW 3.x under Visual C++/Intel compilers


Important: If you want to compile FFTW as a DLL, you should add a line #define FFTW_DLL to fftw3.h and ifftw.h before compiling. This will add the requisite __declspec decorations to function declarations etc. Project files to compile FFTW 3.2.1 with Visual Studio 2008 were sent to us by Nathaniel Meyer (nate at nutty dot ca): fftw-3.2-vs2008.zip. Project files to compile FFTW 3.1.2 with the Intel compilers under Visual Studio .NET 2003 were sent to us by Jin Tian (jintian at nlsde dot buaa dot edu dot cn): fftw-3.1.2-vs2003.zip. Franz Franchetti has graciously offered to provide up-to-date FFTW binaries and project files using Visual Studio and the Intel C compiler at his web page.

DLLs and wisdom

2 de 6

15/08/2009 06:00 p.m.

FFTW Installation on Windows

http://www.fftw.org/install/windows.html#fftw2

FFTW implements a mechanism called "wisdom" for saving plans to disk (see the manual). However, users have reported that passing FILE pointers to a DLL fails (i/o in the DLL crashes). This has been reported for FFTW compiled with both gcc/MinGW and the Intel compilers, and it's been suggested to us that this has to do with there being multiple C runtime libraries in Windows (see here). Because of this, you currently cannot call FFTW's fftw_export_wisdom_to_file and fftw_import_wisdom_from_file functions when FFTW is compiled as a DLL. There are workarounds, however. In particular, FFTW provides generic import/export functions that allow you to specify a routine for reading/writing characters. That way, you can supply a routine to access the file yourself and the DLL never has to see it. In particular, you can provide a drop-in replacement for FFTW's fftw_export_wisdom_to_file and fftw_import_wisdom_from_file functions simply by including the following lines after you #include <fftw3.h>:
static void my_fftw_write_char(char c, void *f) { fputc(c, (FILE *) f); } #define fftw_export_wisdom_to_file(f) fftw_export_wisdom(my_fftw_write_char, (void*) (f)) #define fftwf_export_wisdom_to_file(f) fftwf_export_wisdom(my_fftw_write_char, (void*) (f)) #define fftwl_export_wisdom_to_file(f) fftwl_export_wisdom(my_fftw_write_char, (void*) (f)) static int my_fftw_read_char(void *f) { return fgetc((FILE *) f); } #define fftw_import_wisdom_from_file(f) fftw_import_wisdom(my_fftw_read_char, (void*) (f)) #define fftwf_import_wisdom_from_file(f) fftwf_import_wisdom(my_fftw_read_char, (void*) (f)) #define fftwl_import_wisdom_from_file(f) fftwl_import_wisdom(my_fftw_read_char, (void*) (f))

Older stuff
Below are older instructions and packages that were sent to us, but which are now probably out of date.

FFTW 3.0.1 and Visual C++/Intel compilers


Alessio Massaro contributed Windows binaries of fftw-3.0.1, compiled with the Intel C Compiler version 7.1. This package uses SSE/SSE2 instructions when appropriate. This archive is called fftw-3.0.1w32-pl1.zip and was created on Nov 13, 2003. If you downloaded the older archive fftw-3.0.1w32.zip, please upgrade. Some library symbols were incorrectly not exported in the older build. Alessio has also sent us Windows binaries compiled with gcc under MinGW, which support for threads and have AMD K7 (3dNow!) in addition to SSE/SSE2. An updated version of this file was contributed by Boran Car, which incorporates a missing libgcc.a library file. This library can be called from Visual C++ and other Windows compilers. Klaus Maisinger contributed .def and .lib files for Borland C++ Builder 6 to to allow you to use the above Intel-compiled binaries; you need to use Klaus' fftw3.lib in addition to fix compatibility problems between Borland C++ and Visual C++. See also his description of what he did. The above binaries were, unfortunately, compiled without the Fortran wrapper routines. Koos Huijssen sent us a library file for Compaq Visual Fortran that you can use, in addition to Alessio's DLL, to call FFTW from that Fortran compiler. Stephane Ruel helped us to get FFTW 3 working under Visual C++, and sent us a build file to compile FFTW with that compiler. (Note that this package provides modified versions of some FFTW files, which are no longer necessary with FFTW version 3.0.1. Also, it refers to the files rdft/vrank2-transpose.c and rdft/vrank3-transpose.c, which are no longer included or needed; references to them should be deleted from the build, or you can create empty files with these names. Other compiler warnings can be ignored.) Mark Roden send us modified build files to use Visual C++ 6.0 with version 8.0 of the Intel compiler and FFTW 3.0.1, with threads and SSE enabled.

Visual C++ Problems


Visual C++ is buggy. Get a real compiler and do not complain to us. Stephane Ruel was unable to get the SIMD (SSE) code to produce correct results with Visual C++ 6.0; we

3 de 6

15/08/2009 06:00 p.m.

FFTW Installation on Windows

http://www.fftw.org/install/windows.html#fftw2

suspect a compiler bug (the same code works fine with gcc and Intel icc). We have an unconfirmed report of similar problems with version 7.0. If you have a more recent version of VC++, please let us know whether it works. Stephane recently reported that he was able to compile the SIMD code in FFTW 3.0.1 using the Intel compiler version 7.1 (with flags -O3 -G7 -QxW) with Visual C++. (Modify config.h to #define either HAVE_SSE or HAVE_SSE2, depending upon the precision.) Visual C++ 4.0 and 5.0 had some problems compiling previous FFTW versions correctly, but these were fixed in later releases of those compilers, which however introduced new bugs for new FFTW versions. VC++ 6.0 also reportedly produces incorrect code for the file reodft11e-r2hc-odd.c (odd-size type-IV DCTs and DSTs) unless optimizations are disabled for that file.

Visual C++ Project Files and Win32 Binaries for FFTW 2.x
Andrew Sterian has put together project workspace files for Microsoft Visual C++ 5.0 that can be used to build FFTW 2.1.3 smoothly from within the IDE. His workspace also allows building the FFTW library as a DLL. Please read through the README.TXT file for important information about using FFTW as a DLL. You should note that the FFTW package can be compiled as-is on Windows--you simply need to compile all of the .c files in the fftw and rfftw directories. Andrew's files may provide extra convenience, however, especially when building DLLs. Andrew's package also includes some code to allow the test program to accept command-line parameters in the DOS shell (otherwise, the test program will run in interactive mode on Windows). You can also find the latest versions of Andrew's packages, as well as prebuilt binaries for Win32 (x86) on his web site.

FFTW 3.x and Borland Delphi


George Beckett has contributed a Pascal interface file (fftw_interface.pas) for calling FFTW from Borland Delphi (Pascal). This file is for the single-precision FFTW, but double-precision could be used as well by changing the appropriate types and renaming fftwf_ to fftw_ in the file. He also sent us his notes on calling FFTW from Delphi as well as on compiling FFTW on Windows with the Borland C++ compiler. Finally, he sent us the compiled library via Borland (see also the material from Klaus Maisinger, above). George recommends using the DLLs from Alessio Massaro instead, though, for better performance (note that Alessio's symbol names do not need to be prepended with an underscore, however).

FFTW 2.x and Dev-C++/MinGW


Marek Januszewski has created an FFTW 2.x DevPak for use with Dev-C++ (a MinGW front-end).

Alignment with FFTW 2.x


FFTW includes special hacks to align double-precision variables on the stack for gcc on x86. One of our users, Jonathan Hardwick, has done a detailed study of how these hacks might be extended to Visual C++ and the Intel C++ compiler, and what their performance effects are.

Fortran with FFTW 2.x


FFTW can include Fortran-callable wrapper routines so that you can call the FFTW functions from a Fortran program. These routines are not available automatically on Windows, however. The problem is that FFTW does not know how to mangle its subroutine names for the Fortran linker (Fortran expects all identifiers to be in a canonical case and format). On Unix systems, our configure script can

4 de 6

15/08/2009 06:00 p.m.

FFTW Installation on Windows

http://www.fftw.org/install/windows.html#fftw2

automatically detect the name-mangling scheme, but this is not possible on Windows. So, you have to specify it manually in order to use the Fortran wrappers. To do this, go to the end of the fftw/config.h file and #define the appropriate symbol according to the comments. There are eight possibilities: all upper or lower case, and zero, one, or two appended underscores. For example, Digital Visual Fortran (reportedly) uses all lower case with no appended underscore, so you should #define FFTW_FORTRANIZE_LOWERCASE. (If you don't know, you can experiment with a small Fortran and C program until you find something that works. Your Fortran manual may also document how to link with C.) Let us know how it works with your Fortran compiler. There is another issue to be aware of with Digital Fortran: for every routine that you want to call (e.g. fftw_f77), you must include an instruction like the following at the beginning of your Fortran program:
!DEC$ ATTRIBUTES C, REFERENCE :: fftw_f77

(Thanks to Dima Berkov for this note.)

Timer with FFTW 2.x


FFTW includes a high-precision timer that will be automatically (see below) enabled under Win32, contributed by Andrew Sterian. We have not tested this code ourselves, however, and it may cause problems for some users. (In particular, problems have been reported with its use of the header file windows.h, which is not recognized in some configurations.) To disable the use of this timing code (and revert to the default clock() function), comment out the line:
#define HAVE_WIN32_TIMER

in config.h. If you want to make sure that the timer is automatically enabled in your compiler, delete the #if directive surrounding the above line. (This directive is used to automatically enable the timer, but it won't work if your compiler doesn't define __WIN32__, WIN32, or _WINDOWS. Visual C++ and Borland C/C++ should be fine.)

Watcom with FFTW 2.x


Daniel Q. Naiman emailed us to say that he got FFTW running under Watcom's C compiler, version 10.6. He had to #include the file watcom\h\nt\windows.h in config.h to get things running (presumably because of the timer code).

FFTW 1.2
Here are some changes to the Makefile sent in by Robert Jansen to get FFTW 1.2 running under the DOS shell with gcc:
RM = del CP = copy AR = ar

In the library compilation part, use:


$(AR) rv $(LIBFFT) *.o

due to argument number constraints in make (there are likely other work-arounds). Change $(RM) -f to $(RM) Remove all _64 modules in config.c and the Makefile due to a stack limit problem. (This might be solved by simply increasing the stack size in config.sys; he didn't check.) (Many of these changes may not be necessary with other compilers or if you install a DOS-UNIX package like like uxut123 from the Oakland software repository.)

5 de 6

15/08/2009 06:00 p.m.

FFTW Installation on Windows

http://www.fftw.org/install/windows.html#fftw2

Be sure to let us know if you have to make any other changes to get things working under Windows. Go back to the FFTW download page.

6 de 6

15/08/2009 06:00 p.m.

You might also like