如何使FFTW ++在Windows上运行? (对于假人) [英] How to get FFTW++ working on windows? (for dummies)
问题描述
我正在使用Windows 10和Visual Studio2015.在C ++中,我需要获取图像的傅立叶变换,以便在其上应用滤镜.看来FFTW ++是实现此目的的理想解决方案,但是我无法对其进行编译,这使我发疯.我是编程的新手,所以我不知道这有多尴尬.
I'm using Windows 10 and Visual Studio 2015. In C++, I need to get the Fourier-transform of an image for applying filters on it. It seems that FFTW++ is the ideal solution for this, however I can't get it to compile, and its driving me mad. I'm relatively new to programming so I don't know how embarrassing this is.
我在Visual Studio中使用了NuGet函数来获取FFTW库. 由于我在NuGet上找不到它,因此我从以下链接下载了FFTW +内容: https://sourceforge.net/projects/fftwpp/ 我将下载内容复制到项目文件夹,并将头文件包含在解决方案资源管理器中.但是它没有编译,引发了许多奇怪的错误(例如:在seconds.h中,它说一些获取时区的函数已过时,而在fftww ++.h中,它说std :: max是非法的)
I used the NuGet function in Visual Studio to get the FFTW library. Since I couldn't find it on NuGet I downloaded the FFTW+ stuff from the following link: https://sourceforge.net/projects/fftwpp/ I copied the content of the download to the project folder, and included the header files in the solution explorer. But it didn't compile, thrown many-many weird errors (for example: in the seconds.h it said that some function which gets the timezone is obsolete, and in the fftww++.h it said that std::max is illegal).
因此,在看到这行不通之后,我回到了FFTW网站,并尝试使用Windows安装指南. http://www.fftw.org/install/windows.html 我下载了64位版本,但我完全不知道如何执行库导入操作,甚至不知道该执行什么操作. i.imgur.com/Qs7mFQT.png 这就是我所得到的,我完全迷路了.
So after seeing that this isn't going to work I went back to the FFTW website, and tried using the Windows installation guide. http://www.fftw.org/install/windows.html I downloaded the 64-bit version, and I have absolutely no idea how to do the library import thing, or even what it does. i.imgur.com/Qs7mFQT.png This is all I get, I'm completely lost.
如何获取它进行编译? 请,如果可以的话:给我写一个尽可能详细的使用说明,我可能很愚蠢,但是我根本不知道发生了什么,而且我在Google上找不到任何类似的教程.>
How can I get it to compile? Please if you can: write me an explanation as detailed as possible on how to use this thing, I may be dumb but I literally have no idea what is going on, and I can't find any tutorial-like on Google.
推荐答案
获取64位预编译的FFTW 3.3.5 Windows DLL
- 从 fftw-3.3.5-dll64.zip <下载/a>
- 解压缩文件.
创建导入库(.lib文件)
- 有关FFTW的官方说明,请此处.
- 有关如何将DLL链接到Visual Studio C ++程序的背景,此MSDN文章将可执行文件链接到DLL ,尤其是有关 隐式的部分链接 很有帮助.
- 在解压缩位置的README-WINDOWS中也很有帮助.
-
打开Visual Studio开发人员命令提示符
- 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
- 导航到开始-> 所有应用-> Visual Studio 2015 -> 开发人员命令提示符
- 在我的计算机上,位置为C:\ Program Files(x86)\ Microsoft Visual Studio 14.0 \ Common7 \ Tools \ VsDevCmd.bat
- 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.0\Common7\Tools\VsDevCmd.bat
导航至解压缩位置并输入
Navigate to the unzip location and type
lib /machine:x64 /def:libfftw3-3.def
(对于单精度或双精度双精度,请使用libfftw3f-3.def或libfftw3l-3.def)
(for single or long-double precision use libfftw3f-3.def or libfftw3l-3.def)
- 这将产生libfftw3-3.lib
- 请注意,这是针对x64的.
打开Visual Studio并创建一个C ++控制台应用程序
- 创建C ++控制台应用程序
- 接受所有默认设置
- 将解决方案平台设置为x64
- Create a C++ Console application
- Accept all the default settings
- Set the solution platform to x64
告诉Visual Studio哪里可以找到FFTW头文件.
(取自此 SO答案.)
执行此操作的方法有多种,这是一种方法.
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.
(或者,可以将.h文件复制到Visual Studio项目文件夹中.)
(Alternatively, the .h file can be copied into the Visual Studio project folder.)
告诉Visual Studio哪里可以找到FFTW导入库.
- 右键单击项目,然后选择属性.
- 添加其他库目录.这将是解压缩位置.
- 添加其他依赖项.键入先前创建的.lib文件(libfftw3-3.lib).
- 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).
创建示例程序
(摘自 FFTW教程. )
#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;
}
编译
告诉Windows在哪里找到FFTW DLL 最简单的方法是将FFTW DLL(libfftw3-3.dll)从解压缩位置复制到Visual Studio输出文件夹.
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.
- 在Visual Studio中,右键单击解决方案,然后选择在File Exporer中打开文件夹.
- 导航到.exe输出文件夹(例如fftw_helloworld2 \ x64 \ Debug)
- 复制DLL libfftw3-3.dll
- In Visual Studio right click on the solution and select Open Folder in File Exporer.
- Navigate to the .exe output folder (e.g. fftw_helloworld2\x64\Debug)
- Copy the DLL libfftw3-3.dll
运行/调试
- 设置断点
- 按F5或
- Set a breakpoint
- Press F5 or
这篇关于如何使FFTW ++在Windows上运行? (对于假人)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!