【发布时间】:2015-06-14 17:00:17
【问题描述】:
我正在尝试使用 ndk 为 android 编译一个模块。该库依赖于 glib,所以我使用https://github.com/ieei/glib 构建了它,一切似乎都还不错。但是,当我尝试在我的 Android.mk 文件中使用 glib 模块时,我在运行 ndk-build 时得到以下信息:
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,但似乎无法让任何一个建议的解决方案为我做任何事情(可能是因为我对整个 makefile 东西很陌生)
我的 Android.mk: LOCAL_PATH := $(call my-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)
有人对如何摆脱链接器错误有想法吗?谢谢。
【问题讨论】:
标签: android shell makefile android-ndk glib