Get the 64bit precompiled FFTW 3.3.5 Windows DLL
- Download from fftw-3.3.5-dll64.zip
- Unzip the file.
Create the import library (.lib file)
- The official FFTW instructions are here.
- For background on how to link a DLL to a Visual Studio C++ program this MSDN article Linking an Executable to a DLL especially the part about implicit linking is helpful.
- Also helpful, in the unzip location, README-WINDOWS.
Open the Visual Studio Developer Command prompt
- Navigate to Start -> All Apps -> Visual Studio 2015 -> Developer Command prompt
- On my machine the location is C:Program Files (x86)Microsoft Visual Studio 14.0Common7ToolsVsDevCmd.bat
Navigate to the unzip location and type
lib /machine:x64 /def:libfftw3-3.def
(for single or long-double precision use libfftw3f-3.def or libfftw3l-3.def)
- This will produce libfftw3-3.lib
- Note this is for x64.
Open Visual Studio and Create a C++ Console Application
- Create a C++ Console application
- Accept all the default settings
- Set the solution platform to x64
Tell Visual Studio where to find the FFTW header file.
(Taken from this SO answer.)
There are various ways to do this, here is one way.
- In the solution explorer, right click on the project and select properties.
- Add additional include directories. This will be the unzip location.
(Alternatively, the .h file can be copied into the Visual Studio project folder.)
Tell Visual Studio where to find the FFTW import library.
- Right click on the project and select properties.
- Add additional library directories. This will be the unzip location.
- Add additional dependency. Type in the .lib file created earlier (libfftw3-3.lib).
Create a sample program
(From the FFTW tutorial.)
#include "stdafx.h"
#include <fftw3.h>
int main()
{
fftw_complex *in, *out;
fftw_plan p;
int N = 32;
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);
fftw_execute(p); /* repeat as needed */
fftw_destroy_plan(p);
fftw_free(in); fftw_free(out);
return 0;
}
Compile
Tell Windows where to find the FFTW DLL
The easiest way is to copy the FFTW DLL (libfftw3-3.dll) from the unzip location to the Visual Studio output folder.
- In Visual Studio right click on the solution and select Open Folder in File Exporer.
- Navigate to the .exe output folder (e.g. fftw_helloworld2x64Debug)
- Copy the DLL libfftw3-3.dll
Run / Debug
- Set a breakpoint
- Press F5 or
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…