【问题标题】:Linking error with 3rd party library in Qt Creator与 Qt Creator 中的第 3 方库链接错误
【发布时间】:2015-09-25 13:59:37
【问题描述】:

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

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_ALLOCAconfig.h 中定义在opus/win32 中。从我所见,文件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。

【问题讨论】:

    标签: c++ c linker opus


    【解决方案1】:

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

    #define VAR_ARRAYS 1
    

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

    $ emcc -D VAR_ARRAYS -D OPUS_BUILD ...
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-02-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多