在eclipse里配置Android ndk环境 适用于windows mac 和linux[转]
由于做Android在底層有庫的時候需要交叉編譯環境,c代碼需要用ndk-build來進行編譯,而java代碼則需要用Android sdk編譯。之前由于對eclipse ide不太熟悉,所以往往編譯的時候都是在記事本里寫好c代碼,然后用cygwin搭建ndk-build環境,用ndk-build來編譯出相關的so之后再用eclipse里去編譯java程序,從而使用該so。
? ? ? 其實并不用這么復雜,利用eclipse完全可以達到編譯so的目的
? ?
? ? 點擊project->builders->new->Program
然后選擇Location
在windows下為
D:\Android\ndk\ndk\ndk-r7-windows\ndk-build.cmd
在linux和mac下為可執行的ndk-build路徑
然后選擇
Working Directory
D:\Android\ndk\ndk\android-ndk-r6b\samples\<your jni project name>
選擇到您對應的jni路徑,然后在我們編譯運行的時候,這個builder就會自動地去編譯so庫,而sdk會去編譯java代碼,實現利用eclipse實現交叉編譯
?
如果還有疑問,可以看這篇文章
http://mobilepearls.com/labs/ndk-builder-in-eclipse/
?
Mobile PearlsLabsSetting up Automatic NDK Builds in EclipseSetting up Automatic NDK Builds in Eclipse
When editing native JNI code in an Android project using the?Android NDK?you may configure Eclipse to automatically 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?ndk-build?binary):
Start by right clicking on your android project (named?hello-neon?in the below screenshots) with JNI resources, and select?Properties. In the resulting dialog, choose the?Builders?entry in the list to the left and press the?New...?button:
A new dialog will open presenting a list of builder types. Select the?Program?type and press the?OK?button:
In the?Main?tab, fill in the following:
Name:The result should look something like the below:
Now continue with the refresh tab. Make sure the two checkboxes?Refresh resources upon completion.?and?Recursively include sub-foldersare checked. Choose the?Specific resources?radio button and press the?Specify Resources...?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?Finish?button:
Now skip the?Environment?tab and go to the final?Build Options?tab. Make sure the?Run the builder: During auto builds?checkbox is checked.
Since the NDK build only needs to happen when editing files in the?jni?folder, check that folder and press the?Finish?button.
Now finally press?OK?in the builder configuration dialog - the new NDK builder should now be up and running. Try editing any file in the?jni?folder and check that the?Console?view produces output from the build process:
from:http://blog.csdn.net/zengyangtech/article/details/7019350 歡迎加群互相學習,共同進步。QQ群:iOS: 58099570 | Android: 330987132 | Go:217696290 | Python:336880185 | 做人要厚道,轉載請注明出處!http://www.cnblogs.com/sunshine-anycall/p/3391438.html總結
以上是生活随笔為你收集整理的在eclipse里配置Android ndk环境 适用于windows mac 和linux[转]的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 深入理解计算机系统-之-数值存储(六)-
- 下一篇: DP——最优矩阵链乘最优三角剖分