在android ndk eclipse中链接第三方库

时间:2015-10-13 06:22:01

标签: android android-ndk glib

我在android ndk eclipse中编译了glib库(用localgmib创建了一个libglib.so文件作为libglib)。但是我得到了could not be resolved errors内置的glib功能。

这是我的android.mk文件:

    LOCAL_PATH := $(call my-dir)

    include $(CLEAR_VARS)
    include $(call all-subdir-makefiles)
    LOCAL_LDLIBS    := -llog
    LOCAL_MODULE    := mycode
    LOCAL_SRC_FILES := mycode.c
    LOCAL_SHARED_LIBRARIES := libglib 
    LOCAL_C_INCLUDES += $(LOCAL_PATH)/../glib/
    LOCAL_C_INCLUDES += $(LOCAL_PATH)/../glib/glib/

    include $(BUILD_SHARED_LIBRARY)

我错过了什么?

2 个答案:

答案 0 :(得分:0)

我认为您必须将其更改为

 LOCAL_SHARED_LIBRARIES := glib # for libglib.so

https://stackoverflow.com/a/24138372/755804,这些东西有效。

答案 1 :(得分:0)

我认为你的Android.mk应该是这样的:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE    := libglib
LOCAL_SRC_FILES := ../glib/glib.c
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../glib/
include $(BUILD_SHARED_LIBRARY)


include $(CLEAR_VARS)
LOCAL_MODULE    := mycode
LOCAL_C_INCLUDES := $(LOCAL_PATH) \
                $(LOCAL_PATH)/../glib/
LOCAL_SRC_FILES := mycode.c
LOCAL_LDLIBS    := -llog
LOCAL_SHARED_LIBRARIES := libglib
include $(BUILD_SHARED_LIBRARY)

第一部分构建libglib.so。 然后,您可以让模块mycode依赖它。