在Android上使用glib:未定义的引用'g_thread_init'
问题描述:
我想为使用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)
任何人都有想法如何获得摆脱链接器错误?谢谢。
答
我想通了!实际上有几个共享对象库在创建glib时创建,我缺少的是libgthread-2.0.so。
我将libgthread-2.0.so添加到了我的LOCAL_LDLIBS中,它工作了