【问题标题】:C++ FFTW3 linking error [duplicate]C ++ FFTW3链接错误[重复]
【发布时间】:2013-02-26 14:43:05
【问题描述】:

每当我尝试使用 FFTW3 实现编译 C++ 程序时,都会遇到非常奇怪的错误。

我编译如下

g++ -O3 -lm -lfftw3 myFile.cpp -o myFileFFTW

我还包括我的头文件如下

#include <math.h> #include "fftw3.h"

报错如下

(.text+0x63): 对 `fftw_malloc' 的未定义引用

有什么建议吗?

编辑:

hmjd 的建议对我有用。 Linker errors when compiling against glib...?

我想一个人不应该连续工作 3 天,否则头脑不工作! 特别感谢hmjd!!你拯救了我的一天,我可以按时完成我的项目!!

【问题讨论】:

  • 最后的库:g++ -O3 myFile.cpp -o myFileFFTW -lm -lfftw3 stackoverflow.com/questions/9966959/…
  • 是的。有效 !!非常感谢!!!!
  • 对于任何读过这篇文章但不明白解决方案是什么的人,答案是将链接器标志放在编译命令的末尾,正如 hmjd 显示但没有解释的那样。

标签: c++ fftw ubuntu-12.10


【解决方案1】:

我猜问题是您的系统上不存在 -lfftw3 并且您也没有正确指定库。

编译器命令末尾的库:

gcc -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include re.c -o re -lglib-2.0

来自 GCC 链接选项:

-图书馆 -l 库 链接时搜索名为 library 的库。 (将库作为单独参数的第二种选择 仅用于 POSIX 合规性,不推荐使用。)

It makes a difference where in the command you write this option;
the linker searches and processes libraries and object files in the
order they are specified.
Thus, `foo.o -lz bar.o' searches library `z' after file foo.o but
before bar.o. If bar.o refers to functions in `z', those functions
may not be loaded.

来自Linker errors when compiling against glib...?的片段

【讨论】:

    猜你喜欢
    • 2018-08-23
    • 2010-11-24
    • 2015-04-16
    • 2014-08-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多