Thursday, January 17, 2013

Error "Program bash not found in PATH" when building cocos2dx with eclipse cdt build command

Setting up Cocos2dx Android project is tricky. Though this article is very good as a guidance, I still got some problems. One is
When setting the command build in eclipse CDT with the command
bash ${ProjDirPath}/build_native.sh NDK_DEBUG=1 V=1
it complained
"Program "[path]/bash" not found in PATH".
However, we need to use build_native.sh to build the project because Cocos2dx team has done it well and it also configured paths for cocos2dx project(though you can do your own as long as you want to challenge yourself on this). So we need to find a way to run the build_native.sh.

After blood sweat and tears, I found out that this was because I used the NDK plugin to convert the project into C++ project and NDK plugin set builder Android Builder as below

Then the eclipse will be using Android NDK settings to build to project and could not recognise the bash command.

If you use "add native support" to convert the project to C++ project by Android tools and met the same problem. Switch the current builder to GNU Maker Builder, problem fixed!

Make sure you go back c/c++ Build option to reset the build command line to 
bash ${ProjDirPath}/build_native.sh NDK_DEBUG=1 V=1
as switching current builder will reset build command to default one!