[英]Linking error with 3rd party library in Qt Creator
我需要將 pcm 數據解碼為 opus 格式。 因此,我想將 opus 源包含在我的項目中,但我無法鏈接文件。 我從這里下載了源文件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/win32
config.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 ...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.