Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build shared library linking to other not standard shared libarary

I have some two shared libraries and header for them. I want to build third shared library using functions from previous two libs. Have problem with makefile i think. When i try to build receive this:

Android NDK: /cygdrive/d/.../jni/Android.mk: Cannot find module with tag 'shared1' in import path
Android NDK: Are you sure your NDK_MODULE_PATH variable is properly defined ?
Android NDK: The following directories were searched:
Android NDK:
/cygdrive/d/.../jni/Android.mk:36: *** Android NDK: Aborting.    .  Stop.

structure of my project:

jni/
 - myfile.c
 - Android.mk
   jni/dec/
     - lot of header files
   jni/enc/
     - lot of header files
libs/armeabi/
 - shared1.so
 - shared2.so

also Android.mk sourse:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_C_INCLUDES :=   \
    $(LOCAL_PATH)/dec \
    $(LOCAL_PATH)/enc 

LOCAL_SHARED_LIBRARIES := shared1 shared2

LOCAL_MODULE    := mylib
LOCAL_SRC_FILES := myfile.c
LOCAL_LDLIBS    += -lOpenSLES
LOCAL_LDLIBS    += -llog
LOCAL_LDLIBS    += -landroid

include $(BUILD_SHARED_LIBRARY)

$(call import-module, shared1)
$(call import-module, shared2)
like image 314
xitx Avatar asked Mar 01 '12 14:03

xitx


People also ask

Can shared library link to another shared library?

However, most shared library systems are restricted in that they only allow a single level of dependencies. In these systems, programs may depend on shared libraries, but shared libraries may not depend on other shared libraries.

Are all libraries linked?

Usually, all the libraries in a county are connected. All the public libraries in a county share common Library Catalog and system. They not only share the catalog, but you can request books from other county libraries too.


1 Answers

Take a look to this question: Android JNI APK Packing

You need to give another name for libs/armeabi/ folder to avoid conflicts with NDK build and add the following code before the include $(CLEAR_VARS) statement:

include $(CLEAR_VARS)
LOCAL_MODULE:=shared1
LOCAL_SRC_FILES:=3rdparty_libs/shared1.so
include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE:=shared2
LOCAL_SRC_FILES:=3rdparty_libs/shared2.so
include $(PREBUILT_SHARED_LIBRARY)
like image 107
Andrey Kamaev Avatar answered Oct 17 '22 19:10

Andrey Kamaev