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 :

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 ****


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


**** 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: If you have the same inconsistency in your PATH variable, follow this entry in StackOverflow:

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)