2015-06-14 102 views
0

我想爲使用ndk的android編譯模塊。該庫對glib有依賴性,所以我使用https://github.com/ieei/glib構建了它,並且一切似乎都正常。然而,當我嘗試使用油嘴模塊在我的Android.mk文件,我得到的運行NDK建造以下:在Android上使用glib:未定義的引用'g_thread_init'

jni/fluidsynth/fluidsynth/fluidsynth/src/fluid_cmd.c:1837: error: undefined reference to 'g_thread_init' 
jni/fluidsynth/fluidsynth/fluidsynth/src/fluid_event.c:647: error: undefined reference to 'g_thread_init' 
jni/fluidsynth/fluidsynth/fluidsynth/src/fluid_midi_router.c:106: error: undefined reference to 'g_thread_init' 
jni/fluidsynth/fluidsynth/fluidsynth/src/fluid_sys.h:161: error: undefined reference to 'g_thread_init' 

我擡起頭來解決這個問題,我發現這一點:http://ragnermagalhaes.blogspot.com/2007/09/undefined-reference-to-gthreadinit.html,但couldn 「T似乎得到任何提出的解決方案來爲我做任何事(可能是因爲我是很新的整個生成文件的東西)

我Android.mk: LOCAL_PATH:= $(叫我-DIR)

include $(CLEAR_VARS) 
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../PdCore/jni/libpd/pure-data/src \ 
            $(LOCAL_PATH)/../glib \ 
            $(LOCAL_PATH)/../glib/glib \ 
            $(LOCAL_PATH)/../glib/gnulib \ 
            $(LOCAL_PATH)/../glib/android \ 
            $(LOCAL_PATH)/fluidsynth/fluidsynth/fluidsynth/include/fluidsynth \ 
            $(LOCAL_PATH)/fluidsynth/fluidsynth/fluidsynth/include 
LOCAL_MODULE := soundfonts 
LOCAL_CFLAGS := -DPD 
LOCAL_CFLAGS += -std=c11 
LOCAL_CFLAGS += -w 
LOCAL_CFLAGS += 
FLUID_SRC := $(wildcard $(LOCAL_PATH)/fluidsynth/fluidsynth/fluidsynth/src/*.c) 
LOCAL_SRC_FILES := $(FLUID_SRC:$(LOCAL_PATH)/%=%) \ 
       soundfonts.c 
LOCAL_LDLIBS := $(LOCAL_PATH)/../glib/libs/armeabi/libglib-2.0.so 
LOCAL_LDLIBS += -L$(LOCAL_PATH)/../PdCore/libs/$(TARGET_ARCH_ABI) -lpd -lgthread-2.0 -lglib-2.0 
include $(BUILD_SHARED_LIBRARY) 

任何人都有想法如何獲得擺脫鏈接器錯誤?謝謝。

回答

0

我想通了!實際上有幾個共享對象庫在創建glib時創建,我缺少的是libgthread-2.0.so。

我將libgthread-2.0.so添加到了我的LOCAL_LDLIBS中,它工作了