I work with Android NDK r6b under cygwin (the system is updated correctly). I am modifying the hello-jni sample to learn how to work with NDK. Since I have a library written in C ++ that I want to use in hello-jni (in fact, I created a prj called helloworld with one .cpp file called ndkfoo.cpp), I created a new Android project in Eclipse (updated for Android), added jni-catalog, added files Android.mk and Application.mk, edited to compile .cpp. At the end of the compilation, I get a .so file .
Now, in helloworld Android.mk, I need to make some changes to tell the linker to enable this library. Suppose the library file is libmylib.so , I have the following android.mk script file:
LOCAL_PATH: = $ (call my-dir)
includes $ (CLEAR_VARS)
LOCAL_MODULE: = ndkfoo
LOCAL_SRC_FILES: = ndkfoo.cpp
LOCAL_C_INCLUDES + = $ (LOCAL_PATH) / mylib
LOCAL_LDLIBS + = -L $ (LOCAL_PATH) /../../ mylib / libs / armeabi / -lmylib
includes $ (BUILD_SHARED_LIBRARY)
My directories are organized as follows:
d:/android/android-ndk-r6b => android ndk root
d:/android/workspace/helloworld => helloworld project
d:/android/workspace/mylib => mylib project library
(so the path to libmylib.so: d: / android / workspace / mylib / libs / armeabi).
, . mylib ndkfoo.cpp, . mylib, , : :
D:/android/android-ndk-r6b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windo
WS//../Library/GCC/--androideabi/4.4.3/../../../../ -androideabi/
bin/ld.exe: -lmylib
Ps.
, ndk-buld jni helloworld.
.
. Visual C/++ IDE, GCC, make .....