So I use the NFFT library for work on a 64 bit Ubuntu Linux machine, where it is relatively easy to compile and set up. All the dependencies are in the linux repositories, and compiling is simple and straightforward. However I wanted to be able to run my matlab code and test scripts on my home machine, running Windows 7 64 bit without dual booting OSes or running a painfully slow VM.
It was a bit of a pain, but I finally succeeded in getting some working binaries up and running. Maybe this will save someone else some time and pain.
You need a suitable compilation environment. I wanted native 64 bit binaries, so my only real choice was to use the 64 bit mingw-32 compiler. I chose to use the cygwin environment to ease the setup of this compiler. Download the cygwin setup.exe from the cygwin homepage.
Run the setup.exe file and when you come to select packages, check at least make and mingw64-x86_64-gcc-core under the devel section.
Open the cygwin terminal. Now we need to obtain the fftw3 library. The FFTW project provides precompied windows binaries, and the best choice here is to use these. Go to the FFTW windows download page, and select the download link for the 64 bit binaries.
As we are using cygwin and have a terminal open I ran
to download the zip file into my cygwin home directory, and
to unzip it into a subdirectory.
The final stage is to rename the fftw dll so that it can be found and properly linked. Simply change into your fftw directory and rename or copy libfftw3-3.dll to libfftw3.dll
cp libfftw3-3.dll libfftw3.dll
Obtain the NFFT source code. The latest version as of July 2012 is 3.2.0 and is available from the NFFT download page.
I ran the following to download and unzip the source:
tar zxvf nfft-3.2.0.tar.gz
Now cd into nfft-3.2.0 and configure the build. The options I chose worked well for me, and they assume that your matlab installation is located in C:\matlab\R2012a, this needs to be changed for different releases and installation locations (nb. My matlab directory was actually C:\Program Files\MATLAB\R2012a, but this caused problems for the nfft build, so I made a windows symlink between C:\Program Files\MATLAB and C:\matlab, to do this open an elevated command prompt, i.e. Start Menu, Type ‘cmd’ and then right click on cmd.exe and Run as administrator. Then run ‘mklink /D C:\matlab “C:\Program Files\MATLAB”‘)
So I ran the following command in the cygwin terminal: (replace jpowell with your username, I didn’t use ~/ style as this seemed to cause problems when building)
./configure --host=x86_64-w64-mingw32 --enable-all -enable-openmp --with-fftw3-libdir=/home/jpowell/fftw-3.3.2/ --with-fftw3-includedir=/home/jpowell/fftw-3.3.2/ --with-matlab=/cygdrive/c/matlab/R2012a/ --with-matlab-arch=win64 --with-matlab-fftw3-libdir=/home/jpowell/fftw-3.3.2/
The critical command here is –host=x86_64-w64-mingw32 this configures the compilation for a mingw-w64 cross compile, and produces binaries that are not linked to cygwin. If the configure script runs without errors you can type
The final step for me was to get the compiled binaries working in my Matlab environment. For me this involved copying the nfft helper functions in C:\cygwin\home\jpowell\nfft-3.2.0\matlab\nfft into a subdirectory in my matlab folder. To simplify things I copied the libnfft.mexw64 file from C:\cygwin\home\jpowell\nfft-3.2.0\matlab\nfft\.libs into the same directory as the helper functions and then renamed it to nfftmex.mexw64.
This nfftmex binary relies on a couple of other dynamic libraries, including libfftw3-3.dll so I copied that into the same directory from C:\cygwin\home\jpowell\fftw-3.3.2. I also need some additional mingw libraries, libgomp-1.dll and pthreadGC2.dll, which can be found in your cygwin install at C:\cygwin\usr\x86_64-w64-mingw32\sys-root\mingw\bin
With all of those installed I can confirm everything is working by running the matlab command nfft_get_num_threads to show that the nfft library is working and taking advantage of all the available threads of my processor.
Let me know if this helps, or if you encounter any problems following the above instructions. Hopefully the changes to make for a 32 bit system or different version of matlab will be easy enough to work out.