extern C的未定义引用

don*_*ote 5 c c++ open-source signal-processing makefile

我正在尝试用Netbeans(g ++)编译一个包含Aquila的程序,这个程序包含开源库.我按照安装说明进行操作.

但是当我尝试编译一个小的测试程序时,我得到了这个错误

In function `Aquila::OouraFft::fft(double const*)':OouraFft.cpp:(.text+0x24f):
undefined reference to `cdft'
Run Code Online (Sandbox Code Playgroud)

OouraFft.h:

#include "Fft.h"

extern "C" {
    void cdft(int, int, double *, int *, double *); //prototypes of offending function
    void rdft(int, int, double *, int *, double *); //second one.
}
Run Code Online (Sandbox Code Playgroud)

libs文件夹中的C文件包含函数的定义.

导致OouraFft.cpp中的实际错误的行:

// let's call the C function from Ooura's package
    cdft(2*N, -1, a, ip, w);
Run Code Online (Sandbox Code Playgroud)

所以我认为外部C文件没有与项目链接,但包含项目目录中的所有目录.我一直在谷歌搜索几个小时,无法弄明白.

小智 5

高达git版本6f5d6b,Aquila的CMake配置默认会生成静态库.您应该复制/path-to-your-build-tree/lib/libOoura_fft.a/path-to-your-install-dir/lib/并将其链接到您的测试程序.

  • 您还必须确保ooura_fft在您的库中链接...我遇到了同样的问题,并认为ooura_fft内容将包含在libAquila.a中.因此,将libOoura_fft.a复制到lib目录,并在makefile中包含-looura_fft. (2认同)