【學習Android NDK開發】搭建Android NDK開發環境(Ubuntu 12.04 LTS 32-bit)


1、安裝make build工具

執行以下命令:

sudo apt-get install build-essential

 

2、下載NDK

官網下載頁:http://developer.android.com/tools/sdk/ndk/index.html

選擇Linux 32/64-bit (x86)版本,下載

下載成功后,解壓到/usr/lib/目錄下

 

3、配置Eclipse插件

a) 搭建SDK開發環境,參考:【學習Android NDK開發】搭建Android SDK開發環境(Ubuntu 12.04 LTS 32-bit)

打開Eclipse,設置NDK路徑,Window -> Preferences -> Android -> NDK

b) 右鍵點擊項目,Android Tools -> Add Native Support

前提:Eclipse成功安裝ADT

 

4、調試

a) 更新C/C++ Build配置

右鍵點擊項目,Properties -> C/C++ Build -> Builder Settings

Builder Command,由"ndk-build"添加參數“NDK_DEBUG=1”

In NDK r5, ndk-build has been modified to make it easier to switch between
release and debug builds. This is done by using the NDK_DEBUG variable.
For example:

  $NDK/ndk-build NDK_DEBUG=1  => forces the generation of debug binaries
  $NDK/ndk-build NDK_DEBUG=0  => forces the generation of release binaries

If you don't specify NDK_DEBUG, ndk-build will keep its default behaviour,
which is to inspect the AndroidManifest.xml, if any, and see if its
<application> element has android:debuggable="true".

IMPORTANT: If you use the build tools of SDK r8 (or higher), you
           won't need to touch your AndroidManifest.xml file at all!

           That's because if you build a debug package (e.g. with
           "ant debug" or the corresponding option of the ADT plugin),
           the tool will  automatically pick the native debug files
           generated with NDK_DEBUG=1.

Also, as a convenience, the release and debug object files generated by the
NDK are now stored in different directories (e.g. obj/local/<abi>/objs and
obj/local/<abi>/objs-debug). This avoids having to recompile all your sources
when you switch between these two modes (even when you only modified one or
two source files).

b) 右擊項目,Debug As -> 3 Android Native Application

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM