Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent manually added libraries from being deleted by ndk-build

Tags:

I have a project which is reusing a native library (libocr.so) pre-compiled and for which I don't have source files. I manually put the library on libs/armeabi of my project and everything works perfectly.

Then I needed to create a new native library to the same project. I put my source code as weel as the Android.mk file in my jni folder and I build it with ndk-buld command. The library is build and placed in libs/armeabi folder, but libocr.so (the one manually added) is automatically deleted from there... How can I prevent libocr.so from being deleted?

Here is my Android.mk file:

LOCAL_PATH := $(call my-dir)  include $(CLEAR_VARS)  LOCAL_MODULE    := libyuv LOCAL_SRC_FILES := ycrcbutils.c  include $(BUILD_SHARED_LIBRARY) 

Thanks in advance for any help, Luca.

like image 806
lviggiani Avatar asked Mar 06 '11 11:03

lviggiani


People also ask

What is NDK Sysroot?

$NDK/sysroot is the unified headers and is what you should be using when compiling. When linking, you should still be using $NDK/platforms/android-$API/arch-$ARCH . We do have a doc explaining how to use unified headers in a custom build system: android.googlesource.com/platform/ndk/+/master/docs/….

What is libc++_ shared so?

Shared runtimesIf your application includes multiple shared libraries, you should use libc++_shared.so . On Android, the libc++ used by the NDK is not the same as the one that's part of the OS. This gives NDK users access to the latest libc++ features and bug fixes even when targeting old versions of Android.

What is Ndk_project_path?

NDK_PROJECT_PATH - the location of your project NDK_APPLICATION_MK - the path of the Application.mk file APP_BUILD_SCRIPT - the path to the Android.mk file. These are needed to override the default values of the build script, which expects things to be in the jni folder.

What is NDK build?

The Native Development Kit (NDK) is a set of tools that allows you to use C and C++ code with Android and provides platform libraries you can use to manage native activities.


1 Answers

...ok I found the answer by myself... according to ndk/docs/PREBUILTS.HTML I changed my Android.mk like this:

LOCAL_PATH := $(call my-dir)  include $(CLEAR_VARS)  LOCAL_LDLIBS := -llog  LOCAL_MODULE    := libyuv LOCAL_SRC_FILES := ycrcbutils.c  include $(BUILD_SHARED_LIBRARY)   # Add prebuilt libocr include $(CLEAR_VARS)  LOCAL_MODULE := libocr LOCAL_SRC_FILES := libocr.so  include $(PREBUILT_SHARED_LIBRARY) 

and placed a copy of my libocr.so under jni folder of my project.

like image 160
lviggiani Avatar answered Sep 25 '22 18:09

lviggiani