Android 編譯NDK

記錄一下自己編譯NDK的方法。目錄結構:

 

  1. ~/src  --android源碼目錄 
  2.  
  3. ~/android-ndk-r6 --google NDK目錄 

1. 編譯系統

 
  1. a. source build/envsetup.sh 
  2. b. choosecombo Device release msm8660_surf eng 
  3. c. make 
2.  build 
 
  1. a.src$ cd ndk/ 
  2. b.src$ ./build/tools/build-ndk-sysroot.sh 會得到 "ndk/build/platforms" 目錄 
  3. c.src$ ./build/tools/build-platforms.sh  得到 ""src/ndk/samples" 跟 "src/ndk/platforms"目錄 

 
3.將我們自己的 src/prebuilt/ 的 toolchain 覆蓋android-ndk-r6 裏面的相應文件
 
  1. a. src$ cp -af build/platforms/android-3 ../android-ndk-r6/platforms/
  2.  
  3. b. src$ cp -af prebuilt/linux-x86/toolchain/arm-linux-androideabi-4.4.x/* 
  4. ../android-ndk-r6/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/
  5.  
  6. c. src$ cp prebuilt/android-arm/gdbserver/gdbserver 
  7. ../android-ndk-r6/toolchains/arm-linux-androideabi-4.4.3/prebuilt/ 
 
4 測試 hello-jni
 
  1. $cd android-ndk-r6/samples/hello-jni 
  2. $ ./../../ndk-build 
  3. Gdbserver 
  4. : [arm-linux-androideabi-4.4.3] 
  5. libs/armeabi/gdbserver 
  6. Gdbsetup : libs/armeabi/gdb.setup 
  7. Compile thumb : hello-jni <= hello-jni.c 
  8. SharedLibrary : libhello-jni.so 
  9. Install 
  10. : libhello-jni.so => libs/armeabi/libhello-jni.so 
  11. BFD: 
  12. ~/android-ndk-r6/samples/hello-jni/libs/armeabi/ 
  13. st0hXUMa: warning: sh_link not set for section `.ARM.exidx' 
  14.  
  15. build成功 
  16.  
  17. 5. In Eclipse: 
  18. a.Click File > New Android Project... 
  19. b.Select the Create project from existing source radio button. 
  20. c.Select any API level above Android 3.1. 
  21. d.In the Location field, click Browse... and select the 
  22. <ndk-root>/samples/hello-jni directory. 
  23. e.Click Finish. 
  24. to build 
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章