无法使用 Visual C++ 链接到 fftw 库; Windows 64 位上的 Express
我正在尝试使用 Visual C++ Express 链接到 fftw 库,但在尝试编译时出现链接器错误。我按照网站(http://fftw.org/install/windows.html)的说明,通过使用 lib.exe 程序创建 .lib“导入库”来生成 lib 文件。
我将 .lib 文件添加到“Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib”,并将 fftw3.h 添加到“Program Files (x86)\Microsoft Visual Studio 9.0\VC\include”。然后我将 dll 文件放在“Windows/system32”文件夹中。我通过将库(libfftw3f-3.lib、libfftw3-3.lib、libfftw3l-3.lib)添加到链接器/输入首选项的其他依赖项来链接这些库。当我尝试编译时,出现以下错误:
process_wav.obj : error LNK2019: unresolved external symbol __imp__fftwf_destroy_plan referenced in function _main
process_wav.obj : error LNK2019: unresolved external symbol __imp__fftwf_plan_dft_r2c_1d referenced in function _main
我搜索了堆栈溢出,但大多数答案都解释说需要将库添加到其他依赖项中才能找到。当我将 /verbose:lib 放在命令行选项上时,我得到以下信息:
f
fdf
1>Linking...
1>Searching libraries
1> Searching libfftw3f-3.lib:
1> Searching libfftw3-3.lib:
1> Searching libfftw3l-3.lib:
1> Searching F:\Program Files\Mega-Nerd\libsndfile-win32-bin-1.1.7\libsndfile-1.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbc32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbccp32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\kernel32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\user32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\gdi32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\winspool.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\comdlg32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\advapi32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\shell32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ole32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\oleaut32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\uuid.lib:
1> Searching F:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\MSVCRTD.lib:
1> Searching F:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\OLDNAMES.lib:
1> Searching F:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\msvcprtd.lib:
1> Searching libfftw3f-3.lib:
1> Searching libfftw3-3.lib:
1> Searching libfftw3l-3.lib:
1> Searching F:\Program Files\Mega-Nerd\libsndfile-win32-bin-1.1.7\libsndfile-1.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbc32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbccp32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\kernel32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\user32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\gdi32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\winspool.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\comdlg32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\advapi32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\shell32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ole32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\oleaut32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\uuid.lib:
1> Searching F:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\MSVCRTD.lib:
1> Searching F:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\OLDNAMES.lib:
1> Searching F:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\msvcprtd.lib:
1> Searching libfftw3f-3.lib:
1> Searching libfftw3-3.lib:
1> Searching libfftw3l-3.lib:
1> Searching F:\Program Files\Mega-Nerd\libsndfile-win32-bin-1.1.7\libsndfile-1.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbc32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbccp32.lib:
1>Finished searching libraries
它似乎找到了库,但不知道谁可以找到其中的函数名称。我从一个也使用这个库的网站获得了代码,有趣的是函数名称没有出现在“fftw3.h”中,但我不认为这是问题的原因。
任何帮助将不胜感激,因为我现在不知道该转向哪里。
谢谢。
I'm trying to link to the fftw library using visual c++ express, but am getting linker errors when I try to compile. I generated the lib files as the site (http://fftw.org/install/windows.html) explains by creating .lib "import libraries" using the lib.exe program.
I added the .lib files to "Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib", and fftw3.h to "Program Files (x86)\Microsoft Visual Studio 9.0\VC\include". I then put the dll files in "Windows/system32" folder. I linked the libraries by adding them (libfftw3f-3.lib, libfftw3-3.lib, libfftw3l-3.lib) to additional dependencies on the linker/input preferences. When I try to compile I get the following errors:
process_wav.obj : error LNK2019: unresolved external symbol __imp__fftwf_destroy_plan referenced in function _main
process_wav.obj : error LNK2019: unresolved external symbol __imp__fftwf_plan_dft_r2c_1d referenced in function _main
I searched on stack overflow but most of the answers explain that the libraries need to be added to additional dependencies to be found. When I put /verbose:lib on command line options I get the following:
f
fdf
1>Linking...
1>Searching libraries
1> Searching libfftw3f-3.lib:
1> Searching libfftw3-3.lib:
1> Searching libfftw3l-3.lib:
1> Searching F:\Program Files\Mega-Nerd\libsndfile-win32-bin-1.1.7\libsndfile-1.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbc32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbccp32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\kernel32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\user32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\gdi32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\winspool.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\comdlg32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\advapi32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\shell32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ole32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\oleaut32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\uuid.lib:
1> Searching F:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\MSVCRTD.lib:
1> Searching F:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\OLDNAMES.lib:
1> Searching F:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\msvcprtd.lib:
1> Searching libfftw3f-3.lib:
1> Searching libfftw3-3.lib:
1> Searching libfftw3l-3.lib:
1> Searching F:\Program Files\Mega-Nerd\libsndfile-win32-bin-1.1.7\libsndfile-1.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbc32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbccp32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\kernel32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\user32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\gdi32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\winspool.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\comdlg32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\advapi32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\shell32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ole32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\oleaut32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\uuid.lib:
1> Searching F:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\MSVCRTD.lib:
1> Searching F:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\OLDNAMES.lib:
1> Searching F:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\msvcprtd.lib:
1> Searching libfftw3f-3.lib:
1> Searching libfftw3-3.lib:
1> Searching libfftw3l-3.lib:
1> Searching F:\Program Files\Mega-Nerd\libsndfile-win32-bin-1.1.7\libsndfile-1.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbc32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbccp32.lib:
1>Finished searching libraries
It seems to find the libraries but does not know who to find the function names in them. I got the code from a website which also uses this library, interestingly the function names do not appear in "fftw3.h" but I don't think this is the cause of the problem.
Any help would be greatly appreciated as I'm not sure where to turn now.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
以下步骤在 Visual Studio 2008 中适用于我(来自 http://itkcorner.blogspot.com/2012/01/inclusion-de-fftw-en-visual-studio-2008.html);
从 fftw 组织网站 (http://www.fftw.org/install/windows.html) 下载文件“fftw-3.3dll32.zip”
为了从 Visual C++ 链接到这些 .dll 文件,您需要创建 .lib“导入库”对于它们,可以使用 VC++ 附带的“lib”命令来实现。特别是,运行:
lib /def:libfftw3-3.def
在“工具>”中Visual Studio 2008 命令提示符”无需打开任何项目,只需打开 Visual。进入控制台后,使用“cd”命令进入文件夹所在的根目录,然后运行上面的三行,然后创建“lib”文件。
复制创建库的文件夹,然后将其复制到我们要使用它的项目文件夹中,并将该文件夹重命名为“FFTW_LIBS”。在此文件夹中,必要的文件是具有“.dll”、“.lib”和“fftw3.h”的文件。
将库包含在项目中:“Project >属性>配置属性>链接器>条目>其他依赖项”,然后我们包含三个新的库文件:
libfftw3-3.lib
包含库所在的路径:
一个。 《项目》属性>配置属性>链接器>一般>附加库目录”,我们在那里写“./FFTW_LIBS”。
b. 《项目》属性>配置属性>净化> Environment”,然后我们写“./FFTW_LIBS”。
包含“.dll”文件所在的路径。在“项目>属性>配置属性>净化>环境”。在变量“enviroment”中,我们必须指定文件“libfftw3-3.dll”的位置,并写入“PATH = .\FFTW_LIBS”
完成所有这些步骤后,您只需添加“#include fftw3.h”并使用 fftw 函数!
The following steps work for me in Visual Studio 2008 ( from http://itkcorner.blogspot.com/2012/01/inclusion-de-fftw-en-visual-studio-2008.html );
Download the file “fftw-3.3dll32.zip from fftw org website (http://www.fftw.org/install/windows.html)
In order to link to these .dll files from Visual C++, you need to create .lib "import libraries" for them, and can do so with the "lib" command that comes with VC++. In particular, run:
lib /def:libfftw3-3.def
In “Tools > Visual Studio 2008 Command Prompt” without opening any project, just Visual. Once you are in the console, you go with the ‘cd’ command to the root where the folder is placed and once there you run the three lines above, and then the ‘lib files are created.
Copy the folder where the libs are created and then copy it inside the project folder where we want to use it and rename the folder to “FFTW_LIBS”. In this folder the necessary files are the ones that have the ‘.dll’ , ‘.lib’ and the ‘fftw3.h’.
Inclusion of the libs in the project: “Project > Properties > Configuration Properties > Linker > Entry > Additional dependencies” and then we include the three new libs files:
libfftw3-3.lib
Inclusion of the path where the libs are:
a. “Project > Properties > Configuration Properties > Linker > General > Additional libs directory” , and there we write “./FFTW_LIBS”.
b. “Project > Properties > Configuration Properties > Depuration > Environment” , and there we write “./FFTW_LIBS”.
Inclusion of the path where the ‘.dll’ file is. In “Project > Properties > Configuration Properties > Depuration > Environment”. In the variable ‘enviroment’ we have to specify where the file ‘libfftw3-3.dll’ and we write “PATH = .\FFTW_LIBS”
After all of this steps, you just have to add “ #include fftw3.h” and use the fftw functions!
我将介绍对 Antonio 的步骤的轻微修改:
以下内容适用于我的 Windwos 10、Visual Studio 2017、32 位应用程序、x64 计算机:
下载预编译的 FFTW 3.3.5 Windows DLL 并提取 .zip 文件
http://www.fftw.org/install/windows.html
打开 VS 2017 RC 的开发人员 cmd 提示符并转到提取的
文件夹
按如下方式运行 lib 应用程序以创建导入库
(.lib 文件)来自 .dll 库:
<前><代码> lib /def:libfftw3-3.def
lib /def:libfftw3f-3.def
lib /def:libfftw3l-3.def
将以下文件复制到新文件夹中,将该新文件夹命名为 fftw_lib:
<前><代码> fftw3.h
libfftw3-3.lib
libfftw3f-3.lib
libfftw3l-3.lib
libfftw3-3.dll
libfftw3f-3.dll
libfftw3l-3.dll
将“fftw_lib”文件夹复制到项目文件夹中
告诉链接器在项目中包含 .lib 文件:
Project >属性>配置属性>链接器>条目>附加依赖项=
项目>属性>配置属性>链接器>一般>附加库目录 =
项目>属性>配置属性> C/C++>一般>附加包含目录=
Project >属性>配置属性>调试>环境=
结束!
I will introduce a slight modification to Antonio's steps:
Following worked for me on Windwos 10, Visual Studio 2017, 32bit application, x64 computer:
Download precompiled FFTW 3.3.5 Windows DLLs and extract the .zip file
http://www.fftw.org/install/windows.html
Open a developer cmd prompt for VS 2017 RC and go to the extracted
folder
Run the lib application as follows to create the import libraries
(.lib files) from the .dll libraries:
Copy the following files into a new folder, call that new folder fftw_lib:
Copy the "fftw_lib" folder into your project's folder
Tell the linker to include the .lib files in your project:
Project > Properties > Configuration Properties > Linker > Entry > Additional dependencies =
Project > Properties > Configuration Properties > Linker > General > Additional libs directory =
Project > Properties > Configuration Properties > C/C++> General > Additional include directories =
Project > Properties > Configuration Properties > Debugging > Environment =
The End!
也许在运行时它会询问您缺少 fftw dll。
我得到了那个案例,只是将它们放入 system32 文件夹中。
Maybe at runtime it will ask you for fftw dlls missing.
I got that case and simply putted 'em into system32 folder.
我在 64 位 Windows 7 上使用 Visual Studio 2013 Express,在尝试构建 x64 时遇到了与您相同的问题。问题是我使用“VS2013 开发人员命令提示符”shell 中的
lib.exe
生成了.lib
和.exp
。当我从“VS2013 x64 交叉工具命令提示符”shell 重新生成.lib
和.exp
时,所有引用都已解析。I am using Visual Studio 2013 Express on 64-bit Windows 7 and had the same issue as you while trying to build for x64. The problem was that I generated the
.lib
and.exp
usinglib.exe
from "Developer Command Prompt for VS2013" shell. When I regenerated.lib
and.exp
from "VS2013 x64 Cross Tools Command Prompt" shell, then all references were resolved.