FFTW does not have to do too much introduction, is generally used under Linux, including releasing the Windows version of the authors themselves also declared: we don ' t use Windows ourselves
However, due to the mixed programming with mic, I want to use it locally, which has encountered some problems, but also understand a lot of Visual Studio basic configuration.
My system is WINDOWS8 and Visual Studio 2012.
First step: Download the file
To the official website download FFTW64 bit library: http://www.fftw.org/install/windows.html, directly decompression can.
Step two: Generate Lib files using the VS2012 with Lib tool
Enter the following command under the Fftw-3.3.4-dll64 folder:
For the VS Series compiler commands are as follows:
lib/machine:x64/def:libfftw3-3/machine:x64/def:libfftw3f-3/machine:x64/def : libfftw3l-3. def
If not the VS compiler can not specify machine, directly using:
lib/def:libfftw3-3/def:libfftw3f-3/def:libfftw3l-3. def
Tip:lib refers to the lib.exe, if the prompt cannot find this directive, indicating that the environment variable is not matching, add the VS installation path under Path can be
Like mine, D:\Program files (x86) \microsoft Visual Studio 11.0\vc\bin;d:\program files (x86) \microsoft Visual Studio 11.0\vc\ Bin\amd64
If the previous one still does not build successfully, you can use only the following path.
Step three: Configure in the project properties in VS2012
There are 4 main steps:
1. Add header file path:
In the properties-"c/c++=" additionalincludedirectories add fftw-3.3.4-dll64 this folder, so that the program can use Fftw3.h
2. Add the Library path:
Add Fftw-3.3.4-dll64 to this folder in property = "linker=" Additionallibrarydirectories so that the program can use the DLL files in it.
3. Add the library file name:
In the input option under property = "Linker" in the Additionaldependencies, add
Libfftw3-3.lib
Libfftw3f-3.lib
Libfftw3l-3.lib
These three Lib libraries, so that the program can use the Lib file.
4. Copy the dynamic library to the project's code directory (the directory containing the vcxproj)
Libfftw3-3.dll
Libfftw3f-3.dll
Libfftw3l-3.dll
TIP: I have been copying the 64-bit DLL file after the appearance: The application does not start the 0xc000007b problem, and then my other configuration method is unchanged, from the 32-bit folder to copy the three DLL library, the program can run normally.
Fourth step: Test the Code
#include "fftw3.h" #include <stdio.h> #define N 8 int main()
{ int i;
fftw_complex *din,*out;
fftw_plan p;
din = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * N); out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * N); if((din==NULL)||(out==NULL))
{
printf("Error:insufficient available memory\n");
} else { for(i=0; i<N; i++)/*测试数据*/ {
din[i][0] = i+1;
din[i][1] = 0;
}
}
p = fftw_plan_dft_1d(N, din, out, FFTW_FORWARD,FFTW_ESTIMATE);
fftw_execute(p);
fftw_destroy_plan(p);
fftw_cleanup(); for(i=0;i<N;i++)
{
printf("%f,%fi\n",din[i][0],din[i][1]);
}
printf("\n"); for(i=0;i<N;i++)
{
printf("%f,%fi\n",out[i][0],out[i][1]);
} if(din!=NULL) fftw_free(din); if(out!=NULL) fftw_free(out);
getchar(); return 0;
}
Using the FFTW library in Visual Studio