0

I have compiled glib library(created a libglib.so file with local_module as libglib) in android ndk eclipse. But I am getting could not be resolved errors for the inbuilt functions of glib.

This is my android.mk file:

    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)

What am I missing?

re3el
  • 735
  • 2
  • 12
  • 28

2 Answers2

0

I think you have to change it to

 LOCAL_SHARED_LIBRARIES := glib # for libglib.so

see https://stackoverflow.com/a/24138372/755804 , that stuff worked.

Community
  • 1
  • 1
18446744073709551615
  • 16,368
  • 4
  • 94
  • 127
0

I think your Android.mk should be like this :

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)

The first part build the libglib.so. Then you can make your module mycode depend on it.

sonic
  • 1,894
  • 1
  • 18
  • 22
  • It says that local_src_files should end with .so. In my case .so file for glib is built on the go. Hence, there is no libglib.so at the beginning. – re3el Oct 13 '15 at 09:15
  • Ok. I misunderstand your question. In this case change the first part of my answer. Change the line `LOCAL_SRC_FILES := ../glib/` to `LOCAL_SRC_FILES := ../glib/glib.c` (or the appropriate src file for building libglib.so). Then change the line `include $(PREBUILT_SHARED_LIBRARY)` to `include $(BUILD_SHARED_LIBRARY)`. – sonic Oct 13 '15 at 09:41
  • I edit my answer following my comment. Let me know if this work for you. – sonic Oct 13 '15 at 09:43