因此,我試圖在我的Android應用程序的本機代碼上使用libopus。 我Android.mk文件看起來像這樣:在NDK靜態庫中未定義的引用功能
PLATFORM_PREFIX := /opt/android-ext/
LOCAL_PATH := $(PLATFORM_PREFIX)/lib
include $(CLEAR_VARS)
LOCAL_MODULE := libopus
LOCAL_SRC_FILES := libopus.a
include $(PREBUILT_STATIC_LIBRARY)
# I have to redeclare LOCAL_PATH because the library is in /opt/android-ext/
# and my project is somewhere else. Not very elegant.
LOCAL_PATH := /home/sergio/workspace/Project/jni
include $(CLEAR_VARS)
LOCAL_MODULE := opusUtilsNative
LOCAL_SRC_FILES := opusUtilsNative.c
LOCAL_C_INCLUDES += $(PLATFORM_PREFIX)/include
LOCAL_STATIC_LIBRARIES := android_native_app_glue libopus
include $(BUILD_SHARED_LIBRARY)
和我opusUtilsNative.c代碼如下所示:
#include "opusUtilsNative.h"
#include <opus/opus.h>
#include <opus/opus_types.h>
JNIEXPORT jbyteArray JNICALL Java_Project_OpusUtils_encode
(JNIEnv * je, jclass jc, jbyteArray data){
int rc;
opus_int16 * testOutBuffer;
unsigned char* opusBuffer;
OpusDecoder *dec;
dec = opus_decoder_create(48000, 2, &rc);
return data;
}
,當我嘗試建立它,它工作正常只有當我刪除使用「opus_decoder_create」函數的行。否則我會得到這樣的:
error: undefined reference to 'opus_decoder_create'
我可以看到opus_decoder_create上opus.h,這顯然是被包括明確界定,因爲如果我排除這一行,我會得到關於opus_int16和OpusDecoder聲明錯誤。如何納入一些定義,有些不是?
任何幫助將不勝感激。
您是否也知道如何在Windows上跨平臺編譯它?我遇到同樣的錯誤,但我使用的是Visual Studio 2015 +跨平臺工具以及clang和NDK。 – tmighty