記錄一下自己編譯NDK的方法。目錄結構:
- ~/src --Android源碼目錄
- ~/android-ndk-r6 --google NDK目錄
1. 編譯系統
2. build
- a. source build/envsetup.sh
- b. choosecombo Device release msm8660_surf eng
- c. make
3.將我們自己的 src/prebuilt/ 的 toolchain 覆蓋android-ndk-r6 裡面的相應文件
- a.src$ cd ndk/
- b.src$ ./build/tools/build-ndk-sysroot.sh 會得到 "ndk/build/platforms" 目錄
- c.src$ ./build/tools/build-platforms.sh 得到 ""src/ndk/samples" 跟 "src/ndk/platforms"目錄
4 測試 hello-jni
- a. src$ cp -af build/platforms/android-3 ../android-ndk-r6/platforms/
- b. src$ cp -af prebuilt/linux-x86/toolchain/arm-linux-androideabi-4.4.x/*
- ../android-ndk-r6/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/
- c. src$ cp prebuilt/android-arm/gdbserver/gdbserver
- ../android-ndk-r6/toolchains/arm-linux-androideabi-4.4.3/prebuilt/
- $cd android-ndk-r6/samples/hello-jni
- $ ./../../ndk-build
- Gdbserver
- : [arm-linux-androideabi-4.4.3]
- libs/armeabi/gdbserver
- Gdbsetup : libs/armeabi/gdb.setup
- Compile thumb : hello-jni <= hello-jni.c
- SharedLibrary : libhello-jni.so
- Install
- : libhello-jni.so => libs/armeabi/libhello-jni.so
- BFD:
- ~/android-ndk-r6/samples/hello-jni/libs/armeabi/
- st0hXUMa: warning: sh_link not set for section `.ARM.exidx'
- build成功
- 5. In Eclipse:
- a.Click File > New Android Project...
- b.Select the Create project from existing source radio button.
- c.Select any API level above Android 3.1.
- d.In the Location field, click Browse... and select the
- <ndk-root>/samples/hello-jni directory.
- e.Click Finish.
- to build