mohit
mohit

Reputation: 413

Android NDK in ADT and Mac OS (10.8): Cannot run program "/ndk-build": Unknown reason Error: Program "/ndk-build" is not found in PATH

The error while building is

/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]

I am trying to build a OpenCV project on Eclipse ADT and have done the following so far to build it. Normal android projects(not involving c/c++ code) works fine.

1- I have edited the /etc/paths to the following

/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin
PATH=$PATH:/Users/mohitagrawal/adt-bundle-mac-x86_64-20130219/sdk/tools
PATH=$PATH:/Users/mohitagrawal/adt-bundle-mac-x86_64-20130219/sdk/platfor
m-tools
PATH=$PATH:/Users/mohitagrawal/android-ndk-r8e

2- I have edited $PATH to following(knowingly or unknowingly)

    -bash: /opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:
PATH=$PATH:/Users/mohitagrawal/adt-bundle-mac-x86_64-20130219/sdk/tools:PATH=$PATH:/Users/mohitagrawal/adt-bundle-mac-x86_64-20130219/sdk/platfor:m-tools:
PATH=$PATH:/Users/mohitagrawal/android-ndk-r8e:/opt/X11/bin:/usr/local/git/bin:/usr/texbin: No such file or directory

3- Build command in "C/C++ Build" in project properties is set to

${NDK_ROOT}/ndk-build 

4- NDK location in Preferences of ADT eclipse is set to

/Users/mohitagrawal/android-ndk-r8e

Please help me. I am stuck from many days and has even tried on different platform.

Upvotes: 2

Views: 7530

Answers (2)

Goran Horia Mihail
Goran Horia Mihail

Reputation: 3645

I've tried all the solutions that I could find on stackoverflow and none of them worked. In the end I've found this blog.

I'll post the solution here as the link may break in the future:

1. Open up Terminal.
2. Run the following command: sudo nano /etc/paths
3. Enter your password, when prompted.
4. Go to the bottom of the file, and enter the path you wish to add.
5. Hit control-x to quit.
6. Enter "Y" to save the modified buffer.

Upvotes: 5

JonasVautherin
JonasVautherin

Reputation: 8063

You need to change the PATH in Eclipse since it is Eclipse that is trying to run the command. Go to Project Properties > C/C++ Build > Environment > PATH

Add the path to your ndk directory in the PATH variable (i.e. add /Users/mohitagrawal/android-ndk-r8e to the PATH variable).

Moreover, it apparently tries to run /ndk-build. Make sure that in Project Properties > C/C++ Build, "Build command" is ndk-build and not /ndk-build

EDIT: you can also try to build your project from the terminal, by navigating to your project and running the command ndk-build.

Upvotes: 10

Related Questions