0% found this document useful (0 votes)
92 views8 pages

FFTW Installation On Windows

This document provides information on installing FFTW, a library for computing fast Fourier transforms, on Windows systems. It outlines options for using precompiled DLLs, compiling from source using MinGW or Visual Studio, and considerations for using wisdom files with DLLs.

Uploaded by

Jonathan Jaeger
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
92 views8 pages

FFTW Installation On Windows

This document provides information on installing FFTW, a library for computing fast Fourier transforms, on Windows systems. It outlines options for using precompiled DLLs, compiling from source using MinGW or Visual Studio, and considerations for using wisdom files with DLLs.

Uploaded by

Jonathan Jaeger
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

FFTW Installation on Windows

fftw.org/install/windows.html

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.3.5 Windows DLLs


We have created precompiled DLL files for FFTW 3.3.5 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.3.5-dll32.zip (2.6MB)


64-bit version: fftw-3.3.5-dll64.zip (3.1MB)

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:

lib /machine:x64 /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

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.

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, 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:

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:

--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 .

So, for example, to build a double-precision library you might use

./configure --with-our-malloc16 --with-windows-f77-mangling --enable-shared --


disable-static --enable-threads --with-combined-threads --enable-portable-binary --
enable-sse2 --with-incoming-stack-boundary=2
make
make install

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.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.

DLLs and wisdom


FFTW implements a mechanism called "wisdom" for saving plans to disk (see the manual).
FFTW 3.3 includes fftw_export_wisdom_to_filename and
fftw_import_wisdom_from_filename functions where you supply a filename to write/read
to/from, respectively. We believe that these should work fine from Windows DLLs.

However, FFTW also provides fftw_export_wisdom_to_file and


fftw_import_wisdom_from_file routines where you specify a C FILE pointer to a file you
have opened yourself, and users have reported that these routines do not work properly from
DLLs. (These were the only file I/O routines in versions of FFTW prior to 3.3.) It's been
suggested to us that this has to do with there being multiple C runtime libraries in Windows
(see here).

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> :

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
4/8
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.1-w32-pl1.zip and was created on Nov 13, 2003. If you downloaded the
older archive fftw-3.0.1-w32.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 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.

FFTW 3.x and Borland Delphi


An updated Delphi/Pascal interface (fftw3-delphi.zip) was contributed by Serder Kacar, which
includes double and extended precision, wisdom, and threads support, and works with the
precompiled Windows DLLs that we supply above.

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).

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


6/8
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 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
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.)

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.)

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.

8/8

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy