title: Building OpenCV 2.4.5 in android ADT: "ndk-build" not found in PATH
body: <p>I'm trying to follow <a href="http://docs.opencv.org/doc/tutorials/introduction/android_binary_package/O4A_SDK.html" rel="nofollow noreferrer">this OpenCV document</a> to import OpenCV sample projects into the android ADT, and am getting the now infamous "Program "C:\android\android-ndk-r8d-windows\ndk-build" not found in PATH" error. My OS is Windows 7 and I use cygwin for any Linux-like commands.</p>
  
  <p>Please note: I <em>already</em> downloaded the NDK package, and <em>already</em> set the value of NDKROOT to be my NDK root folder. I setup NDKROOT both as a system-wide environmental variable, and as an ADT's C/C++ Build environment variable, as shown below:</p>
  
  <p><img src="https://i.stack.imgur.com/NCG8U.png" alt="enter image description here"></p>
  
  <p>In my NDK root folder, I made identical copies of the file "ndk-build.cmd", and renamed them as "ndk-build" and "ndk-build.sh" respectively. I chmod+x to all three ndk-build* files.</p>
  
  <p>Now what happens is really puzzling: If I specify the C/C++ Build command to be ${NDKROOT}/ndk-build or ${NDKROOT}/ndk-build.sh, I get the error "Program "C:\android\android-ndk-r8d-windows\ndk-build" not found in PATH". However, if I specify it to be ${NDKROOT}/ndk-build.cmd, ADT apparently finds it, but tries to run it as a Windows command, not as a bash script, as shown below:</p>
  
  <p><img src="https://i.stack.imgur.com/yVZQI.png" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/Vy5AF.png" alt="enter image description here"></p>
  
  <p>The only way I can build a project, is to open a cygwin terminal, cd to the sample project folder, and run the script (either ndk-build or ndk-build.sh), like this:</p>
  
  <p><img src="https://i.stack.imgur.com/35oQR.png" alt="enter image description here"></p>
  
  <p>I googled around for a solution. Although there are lots of "ndk-build.cmd not found in PATH" questions, I have not seen a case like mine. What is happening? I might also post my question to the openCV forum.</p>