無論linux還是mac在jni目錄中直接運作 ndk-build 就可以生成 lib目錄及所需要的 so檔案; windows 裝上lnx模拟器也是一樣;
每次修改完 c++代碼, 都要運作一下 ndk-build,然後在 eclipse中運作 java 程式;非常之麻煩; 之是以麻煩,歸根于對強大的eclipse ide環境的不熟悉; 其實 eclipse可以配置 jni的自動編譯選項; 及每次編譯的時候 java 代碼由 java編譯器編譯; 而 jni中的c++代碼,則由 ndk-build來編譯處理(其實裡面也是g++在處理);
關于配置方法,極力推薦以下文章,不懂e文無所謂,看圖檔都明白了。。。
引用網址:http://mobilepearls.com/labs/ndk-builder-in-eclipse/
rebuild your project when editing native code, just as it does for java. the below steps shows how to perform the necessary configuration (note that this requires revision 4 or later of the ndk - previous revisions does not contain the necessary <code>ndk-build</code> binary):
start by right clicking on your android project (named hello-neon in the below screenshots) with jni resources, and select <code>properties</code>. in the resulting dialog, choose the <code>builders</code> entry in the list to the left and press the <code>new...</code> button:

a new dialog will open presenting a list of builder types. select the <code>program</code> type and press the <code>ok</code> button:
in the <code>main</code> tab, fill in the following:
<dl></dl>
<dt>name:</dt>
<dd>ndk builder</dd>
<dt>location:</dt>
<dd>/opt/android-ndk/ndk-build (or wherever your ndk-build binary is). you may use a variable as in ${system_property:user.home}/lib/android-ndk/ndk-build</dd>
<dt>working directory:</dt>
<dd>${workspace_loc:/hello-neon} (replace hello-neon with your project name. press the <code>browse workspace...</code> button to select it graphically)</dd>
the result should look something like the below:
now continue with the refresh tab. make sure the two checkboxes <code>refresh resources upon completion.</code> and <code>recursively include sub-folders</code> are checked. choose the <code>specific resources</code> radio button and press the <code>specify resources...</code> button:
since the ndk-build process will generate files in the lib folder, we want eclipse to discover changes made there without having to refresh manually. so select the lib folder in the project (create one if necessary) and press the <code>finish</code> button:
now skip the <code>environment</code> tab and go to the final <code>build options</code> tab. make sure the <code>run the builder: during auto builds</code> checkbox is checked.
since the ndk build only needs to happen when editing files in the <code>jni</code> folder, check that folder and press the <code>finish</code> button.
now finally press <code>ok</code> in the builder configuration dialog - the new ndk builder should now be up and running. try editing any file in the <code>jni</code>folder and check that the <code>console</code> view produces output from the build process: