NDK HOWTO

来源:互联网 发布:北京理工网络教育官网 编辑:程序博客网 时间:2024/06/05 20:00

如何使用java的NDK轻松调用C或者C++函数库

一   Android添加自己的动态库

在 build/core/prelink-linux-arm.map 或者build/core/prelink-linux-mips.map 加入自己的动态库的定义

原文网址:http://macholad-hotmail-com.javaeye.com/blog/889022

android编译时添加库第三方库文件

android/customization/custom_normal/vendor/third-party/libs/Android_cust.mk 中

include $(CLEAR_VARS)LOCAL_PREBUILT_LIBS += libhello-jni.so include $(BUILD_MULTI_PREBUILT)
在上述mk文件中添加上述代码  可以在编译时将
android/customization/custom_normal/vendor/third-party/libs/libhello-jni.so 库文件添加到android系统库目录中

1  进入工程的目录然后使用   $(NDK)/ndk-build 

ubuntu@ubuntu-desktop:~/android/ToolsForLinux/android-ndk-r4b/samples/hello-jni$ pwd/home/ubuntu/android/ToolsForLinux/android-ndk-r4b/samples/hello-jniubuntu@ubuntu-desktop:~/android/ToolsForLinux/android-ndk-r4b/samples/hello-jni$ ../../ndk-build -B v=1Gdbserver      : [arm-eabi-4.4.0] /home/ubuntu/android/ToolsForLinux/android-ndk-r4b/samples/hello-jni/libs/armeabi/gdbserverGdbsetup       : /home/ubuntu/android/ToolsForLinux/android-ndk-r4b/samples/hello-jni/libs/armeabi/gdb.setupGdbsetup       : + source directory /home/ubuntu/android/ToolsForLinux/android-ndk-r4b/samples/hello-jni/jniCompile thumb  : hello-jni <= /home/ubuntu/android/ToolsForLinux/android-ndk-r4b/samples/hello-jni/jni/hello-jni.cSharedLibrary  : libhello-jni.soInstall        : libhello-jni.so => /home/ubuntu/android/ToolsForLinux/android-ndk-r4b/samples/hello-jni/libs/armeabiubuntu@ubuntu-desktop:~/android/ToolsForLinux/android-ndk-r4b/samples/hello-jni$

2  in apps

a) make file pplication.mk

其中Application.mk 如下:

APP_PROJECT_PATH := /home/ubuntu/android/ToolsForLinux/android-ndk-r4b/apps/hello-jni

b) 

ubuntu@ubuntu-desktop:~/android/ToolsForLinux/android-ndk-r4b$ubuntu@ubuntu-desktop:~/android/ToolsForLinux/android-ndk-r4b$ make APP=hello-jniAndroid NDK: Building for application 'hello-jni'    Gdbserver      : [arm-eabi-4.4.0] /home/ubuntu/android/ToolsForLinux/android-ndk-r4b/apps/hello-jni/libs/armeabi/gdbserverGdbsetup       : /home/ubuntu/android/ToolsForLinux/android-ndk-r4b/apps/hello-jni/libs/armeabi/gdb.setupGdbsetup       : + source directory /home/ubuntu/android/ToolsForLinux/android-ndk-r4b/apps/hello-jni/jniCompile thumb  : hello-jni <= /home/ubuntu/android/ToolsForLinux/android-ndk-r4b/apps/hello-jni/jni/hello-jni.cSharedLibrary  : libhello-jni.soInstall        : libhello-jni.so => /home/ubuntu/android/ToolsForLinux/android-ndk-r4b/apps/hello-jni/libs/armeabiubuntu@ubuntu-desktop:~/android/ToolsForLinux/android-ndk-r4b$



原创粉丝点击