Undefinierter Verweis auf Funktion in statischer Bibliothek mit NDK
Daher versuche ich, libopus in meinem nativen Code für eine Android-Anwendung zu verwenden. Meine Android.mk-Datei sieht folgendermaßen aus:
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)
Und mein Code in opusUtilsNative.c sieht so aus:
#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;
}
Und wenn ich versuche, es zu bauen, funktioniert es gutNur wenn ich die Zeile entferne, die die Funktion "opus_decoder_create" verwendet. Sonst bekomme ich folgendes:
error: undefined reference to 'opus_decoder_create'
Ich kann sehen, dass opus_decoder_create in opus.h klar definiert ist, was eindeutig enthalten ist, da ich, wenn ich diese Zeile ausschließe, eine Fehlermeldung bezüglich der Deklarationen opus_int16 und OpusDecoder erhalte. Wie kommt es, dass einige Definitionen aufgenommen werden und andere nicht?
Jede Hilfe wird sehr geschätzt.