日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

在eclipse里配置Android ndk环境 适用于windows mac 和linux[转]

發(fā)布時(shí)間:2025/7/14 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 在eclipse里配置Android ndk环境 适用于windows mac 和linux[转] 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

由于做Android在底層有庫的時(shí)候需要交叉編譯環(huán)境,c代碼需要用ndk-build來進(jìn)行編譯,而java代碼則需要用Android sdk編譯。之前由于對eclipse ide不太熟悉,所以往往編譯的時(shí)候都是在記事本里寫好c代碼,然后用cygwin搭建ndk-build環(huán)境,用ndk-build來編譯出相關(guān)的so之后再用eclipse里去編譯java程序,從而使用該so。

? ? ? 其實(shí)并不用這么復(fù)雜,利用eclipse完全可以達(dá)到編譯so的目的

? ?

? ? 點(diǎn)擊project->builders->new->Program

然后選擇Location

在windows下為

D:\Android\ndk\ndk\ndk-r7-windows\ndk-build.cmd

在linux和mac下為可執(zhí)行的ndk-build路徑

然后選擇

Working Directory

D:\Android\ndk\ndk\android-ndk-r6b\samples\<your jni project name>

選擇到您對應(yīng)的jni路徑,然后在我們編譯運(yùn)行的時(shí)候,這個(gè)builder就會(huì)自動(dòng)地去編譯so庫,而sdk會(huì)去編譯java代碼,實(shí)現(xiàn)利用eclipse實(shí)現(xiàn)交叉編譯

?

如果還有疑問,可以看這篇文章

http://mobilepearls.com/labs/ndk-builder-in-eclipse/

?

Mobile PearlsLabsSetting up Automatic NDK Builds in Eclipse

Setting 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:
NDK Builder
Location:
/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
Working Directory:
${workspace_loc:/hello-neon} (replace hello-neon with your project name. Press the?Browse Workspace...?button to select it graphically)

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 歡迎加群互相學(xué)習(xí),共同進(jìn)步。QQ群:iOS: 58099570 | Android: 330987132 | Go:217696290 | Python:336880185 | 做人要厚道,轉(zhuǎn)載請注明出處!http://www.cnblogs.com/sunshine-anycall/p/3391438.html

總結(jié)

以上是生活随笔為你收集整理的在eclipse里配置Android ndk环境 适用于windows mac 和linux[转]的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。