gpt4 book ai didi

c++ - Qt libao undefined reference

转载 作者:太空宇宙 更新时间:2023-11-04 08:55:12 24 4
gpt4 key购买 nike

我正在尝试让 libao 库在 Qt 中运行。这是我目前所拥有的。

#include <ao/ao.h>

...

static int audio_driver;
static ao_device *audio_device;
static ao_sample_format audio_format;

...

int main(int argc, char *argv[])
{
QApplication a(argc, argv);

ao_initialize();
audio_driver = ao_default_driver_id();

MainWindow w;
w.show();

return a.exec();
}

它表示对 ao 库中任何内容的每个引用都是 undefined reference 。

error: undefined reference to `ao_initialize'
error: undefined reference to `ao_default_driver_id'

依此类推,贯穿整个代码。

就其值(value)而言,ao/ao.h 中的每个函数都在外部“C”中。

知道是什么原因造成的吗?

非常感谢。

最佳答案

您没有链接到 ao 动态库。

如果您使用 qmake,请在 .pro 文件中添加以下行

LIBS += -lao

如果库在非标准位置,也添加这些行

INCLUDEPATH += path/to/headers
LIBPATH += path/to/library

关于c++ - Qt libao undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17513750/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com