ndk-build not found as a command

13,167

Solution 1

Guess that should have been an answer instead of a comment.

You must use Cygwin as your shell in order to run ndk-build.
See http://www.cygwin.com/

Solution 2

Once you have Cygwin installed you can have Eclipse automatically build your project for you by:

  1. Right click on your project, pick properties.

  2. Select "builders" from the left-hand list.

  3. Click "New..." on the right side.

  4. Select "Program" as the configuration type. I name mine "Native Builder"

    Location - c:\cygwin\bin\bash.exe

    Working Directory - c:\cygwin\bin

    Arguments -

    (for NDK r3): --login -c "cd /cygdrive/c/Android_NDK && make APP=myapp"

    (for NDK r4): --login -c "cd /cygdrive/c/ && /cygdrive/c/Android_NDK/ndk-build"

Make sure you have the two hyphens before login and the quotes after the hyphen-c

  1. Now go to the refresh tab

  2. Check "Refresh resources upon completion"

  3. Select "Specific resources"

  4. Click on the "Specify resources" button and select your project's lib directory.

  5. Check "Recursively include sub-folders"

  6. Now go to the build options tab

  7. Check "Allocate Console"

  8. Check "Launch in background"

  9. Check "Run the builder After a Clean"

  10. Check "Run the builder During manual builds"

  11. Check "Run the builder During auto builds"

  12. Check "Specify working set of relevant resources"

  13. Click on "Specify Resources"

  14. Select your project's JNI directory and all files within.

  15. Now click OK on the bottom.

Now you can edit and save in your c files and it will compile and create the .so file on the fly.

Share:
13,167
user669231
Author by

user669231

Updated on July 25, 2022

Comments

  • user669231
    user669231 almost 2 years

    I have been working with Android SDK for a while & just came across an requirement to use the NDK

    So, I downloaded the Android NDK for Windows. Jumping on the first example, when I am trying to build the library using the process defined in the NDK example

    http://developer.android.com/sdk/ndk/overview.html

    Specifically the command /ndk-build from the command line

    I am getting the error

    ndk-build is not recognized as an internal or external command, operable program or batch file

    I have added the path for ndk-build in the PATH variable and even tried calling the command going to the folder, still the same error

    Does anybody have a clue?

  • Hunt
    Hunt over 11 years
    I followed your approach but i am getting Please install Cygwin make package or define the GNUMAKE variable to point to it. do you have any idea to solve this
  • JPM
    JPM over 11 years
    And your positive that you installed cygwin first? Latest Eclipse version doesn't require you to install cygwin anymore.
  • Hunt
    Hunt over 11 years
    i solve that GNUMAKE error by re installing cygwin but if i set ndk-build without using cygwin in eclipse then i am getting error which says it is not valid win 32 app
  • JPM
    JPM over 11 years
    Sounds like you are mixing 32 and 64 bit programs. You have to make sure all programs are the same bit size
  • JPM
    JPM almost 11 years
    No longer needed in the latest versions of eclipse NDK compiler included in Android tools
  • Nikos Yotis
    Nikos Yotis over 9 years
    definitely wrong. u don't need cygwin. windows prompt compiles just fine