FFTW Installation On Windows
FFTW Installation On Windows
fftw.org/install/windows.html
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
On Visual Studio 2008 in 64-bit mode, and possibly in other cases, you may need to specify
the machine explicitly:
For Borland C++, you instead need to use Borland's implib program, via (thanks to M.
Lenarczyk):
1/8
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.
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, many older versions of VC++ generate
incorrect code for FFTW when SSE/SSE2 is enabled. VC++ 2003 definitely fails. VC++
2005 may work, and VC++ 2010 has been reported to 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 flags—turning 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 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:
There are a few options to our configure script that we especially recommend on Windows:
--disable-alloca : as of this writing (14 July 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).
2/8
--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.
--with-incoming-stack-boundary=2 : compile FFTW assuming a 4-byte alignment. On
win32, some versions of gcc assume that the stack is 16-byte aligned, but code
compiled with other compilers may only guarantee a 4-byte alignment, resulting in
mysterious segfaults.
Either or both of the following to exploit SSE2/AVX (the DLL is still portable because it
checks at runtime to make sure SSE2/AVX is available):
[--enable-float] --enable-sse2 .
[--enable-float] --enable-avx .
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.
Project files to compile FFTW 3.3 with Visual Studio 2010 were sent to us by Long To: fftw-
3.3-libs-visual-studio-2010.zip.
Project files to compile FFTW 3.2.2 with Visual Studio 2010 were sent to us by Long To: fftw-
3.2.2-libs-visual-studio-2010.zip.
Project files to compile FFTW 3.2.2 with Visual Studio 2008 were sent to us by Nathaniel
Meyer (nate at nutty dot ca): fftw-3.2.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.
3/8
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.
We expect that most users will need only the filename functions. However, if you need to
use the fftw_export_wisdom_to_file and fftw_import_wisdom_from_file functions (e.g.
you need to write wisdom to part of a file, and write something else to the rest of the file), then
you can use the following workaround in Windows. 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. 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> :
Older stuff
4/8
Below are older instructions and packages that were sent to us, but which are now probably
out of date.
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.
Stephane Ruel was unable to get the SIMD (SSE) code to produce correct results with Visual
C++ 6.0; we 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.
5/8
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.
Kacar's interface was based on work by George Beckett, who 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. Beckett 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).
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 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:
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
7/8
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.)
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:
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.)
Be sure to let us know if you have to make any other changes to get things working under
Windows.
8/8