«
»

Building native code in Eclipse

May 7, 2012 //
0

After I started using native code in Android projects, I wondered if I can edit and build the c/c++ code from Eclipse. Because every time I needed to edit the native code, it had to do it in XCode and build it on the terminal using ndk-build command. After some research I found that NDK build can be integrated into Eclipse using CDT plugin. Follow the steps from one of these nice web sites :

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

http://mhandroid.wordpress.com/2011/01/23/using-eclipse-for-android-cc-development/

If you followed everything, now your Eclipse should recognize c/c++ code and you can use Eclipse just as some other native development IDE (Visual Studio, XCode…). Unfortunately everything didn’t work out this smooth for me. I received a build error as follows:

**** Build of configuration Default for project AndroidNDK1Sample ****

ndk-build

Cannot run program “ndk-build”: Unknown reason
Error: Program “ndk-build” is not found in PATH

PATH=[/usr/bin:/bin:/usr/sbin:/sbin]

**** Build Finished ****

As you know from my former posts, my PATH variable is not this short and minimal (if I may say :)) Basically, c/c++ builder of Eclipse doesn’t recognize my PATH variable (FYI, I defined PATH in .bash_profile. I am not handy with environment variable declarations in MacOS X. That’s why I had some trouble.. Here is someone who had the same problem as me: http://superuser.com/questions/28344/path-env-variable-on-mac-os-x-and-or-eclipse). If you have the same inconsistency in your PATH variable, follow this entry in StackOverflow:

http://stackoverflow.com/questions/135688/setting-environment-variables-in-os-x/588442#588442

Were you lucky? I wasn’t My solution to this issue ( after spending some afternoon on this, yuck 😦 ) is as follows:

  • Right click your project and open properties
  • Under c/c++ build, go to environment and add a new variable to override PATH having the values in your actual PATH variable (In MacOS X, open terminal and write command env. Copy the PATH string).
  • Clean your project
  • and your PATH is fixed (But only for this project)
Like Loading...
Tags
Categories Uncategorized

0 Comments Post your own or leave a trackback: Trackback URL

Leave a comment Cancel reply

[フレーム]
Design a site like this with WordPress.com
Get started

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /