本文介绍了未定义的参考,外部C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Netbeans(g ++)编译一个包含Aquila的程序,一个开放源代码库 .我遵循了安装说明.

I am trying to compile a program with Netbeans (g++) that inlcudes Aquila, an open source libary. I followed the installation instructions.

但是当尝试编译一个小的测试程序时,出现此错误

But when trying to compile a small test program, I get this error

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

OouraFft.h:

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.
}

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

The C file in the libs folder contains the definition of the functions.

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

The line that cause the actual error inOouraFft.cpp:

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

因此,我认为外部C文件未与项目链接,而是包含了项目目录中的所有目录.我已经搜寻了几个小时,无法解决.

So I am thinking the external C file is not being linked with the project but included all the directories in the project directory.I have been googling for hours and can't figure it out.

推荐答案

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

Up to git version 6f5d6b, Aquila's CMake config will generate static library by default. You should copy /path-to-your-build-tree/lib/libOoura_fft.a to /path-to-your-install-dir/lib/, and link it to your test program.

这篇关于未定义的参考,外部C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 14:53