c++ - Qt Creator 中与第 3 方库的链接错误

标签 c++ c linker opus

我需要将 pcm 数据解码为 opus 格式。 因此我想将作品源包含到我的项目中,但我无法链接这些文件。 我从here下载了源文件opus-1.1.tar.gz 。 在 Qt Creator 中,我将所有文件添加到我的 pro 文件中:

INCLUDEPATH += \
$$PWD/opus/opus/celt \
$$PWD/opus/opus/celt/arm \
$$PWD/opus/opus/celt/tests \
$$PWD/opus/opus/celt/x86 \
$$PWD/opus/opus/silk \
$$PWD/opus/opus/silk/arm \
$$PWD/opus/opus/silk/fixed \
$$PWD/opus/opus/silk/float \
$$PWD/opus/opus/include \
$$PWD/opus/opus/win32

// and here would come an abnormous listing of all c- and h-files of opus:
SOURCES += ... 
HEADERS += ... 

在编译时,我收到来自 stack_alloc.h 的警告

#if (!defined (VAR_ARRAYS) && !defined (USE_ALLOCA) && !defined (NONTHREADSAFE_PSEUDOSTACK))
#error "Opus requires one of VAR_ARRAYS, USE_ALLOCA, or NONTHREADSAFE_PSEUDOSTACK be defined to select the temporary allocation mode."
#endif    

例如,USE_ALLOCA 是在 opus/win32config.h 中定义的。据我所知,文件 config.h 只能像这样被包含:

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

但是在源代码附带的所有文件中我都找不到#define HAVE_CONFIG_H。 此外,在文件config.h中有一个#include "version.h"。该文件也不随源一起提供。我真的不知道如何使用 Opus-lib。这并不是那么难,但我根本找不到运行的最小示例。

我使用的是 Windows 8、mingw 和 c++,但库是 c。

最佳答案

您可以将 -D VAR_ARRAYS 添加到编译命令中或在头文件中定义:

#define VAR_ARRAYS 1

使用 emscripten (WebAssembly) 构建时,我必须添加以下两个标志:

$ emcc -D VAR_ARRAYS -D OPUS_BUILD ...

关于c++ - Qt Creator 中与第 3 方库的链接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31279445/

相关文章:

c++ - 链接问题 DirectX : Linker problem

c++ - MinGW Windows.h 不编译

c - 使用 while 循环的星形图案

c - 在 Linux 上用 C 编写自定义加载器并为 x64 汇编

c++ - 生成文件链接

无法使用 XLoadFont 加载个人字体

c++ - 两个数相减时的小数

c++ - 简单的 C++ 函数

c++ - 如何构建指向 VARIANT 的指针的 SAFEARRAY?

c - 这段代码有什么问题?使用数组输出 C 中整数的最小值、最大值和平均值的程序