Search code examples
android-ndkcygwincocos2d-x

Setting up Cygwin + Android NDK + cocos2Dx to work with Eclipse


I'm following a tutorial from this website: Monetizing Game Apps by Todd Perkins

Access to all the files are not required for the questions I'm asking. I have done research on how to solve this on stack overflow and discussed it below

I have followed the tutorial and it has asked me to:

  1. Install Cygwin
  2. Download Cocos2dx-2.0.1(I know this is old, but I don't want to deal with deprecating problems until I'm more confident with the environment)
  3. Run create-android-project.bat(works fine).
  4. Open project I created- and move to proj.android and run build_native.sh in Cygwin.
  5. Then I open up cygwin.bat, navigate to myproject/proj.android and run ./build_native.sh

Problem:

$ ./build_native.sh Using prebuilt externals ./build_native.sh: line 74: /cygdrive/c/android-ndk-r9c-windows-x86_64/ndk-build: No such file or directory

So I looked into the files and double-checked my changes:

  1. In create-android-project.bat I modified the following variables:

    set _CYGBIN=c:\Cygwin64\bin

set _ANDROIDTOOLS=c:\Program Files (x86)\ADT\adt-bundle-windows-x86_64-20130219\sdk\tools

set _NDKROOT=c:\android-ndk-r9c-windows-x86_64

  1. Check line 74 that cygwin complained about in myproject/proj.android/build_native.sh:

echo "Using prebuilt externals" $NDK_ROOT/ndk-build -C $GAME_ANDROID_ROOT \ NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/prebuilt

  1. Double check what NDK_ROOT is pointing to in build_native.sh:

    NDK_ROOT=/cygdrive/c/android-ndk-r9c-windows-x86_64 COCOS2DX_ROOT=/cygdrive/c/Users/DarkRaveDev/Documents/cocos2d-x-2.0.1 GAME_ROOT=$COCOS2DX_ROOT/chaara GAME_ANDROID_ROOT=$GAME_ROOT/proj.android RESOURCE_ROOT=$GAME_ROOT/Resources

My Research:

I surfed SO for quite some time and tried the following from SO:

  1. EOL Conversion in Notepad++ so LF works for windows for the build_native.sh
  2. An answer somewhere said I need to install the make package when installing cygwin.. I'm not getting this problem, so I'm not sure if this applies.
  3. I have searched many ways to set path - NDK_ROOT

QUESTION:

What exactly am I doing wrong? Is it the variables are badly set or is cygwin not properly installed?


Solution

  • Thank you to everyone who commented! :)

    This is what I ended up doing.

    1. Reinstall Cygwin : When you get to the select packages to install page, make sure to find DEVEL and change the install action from default to install. I know its a lot of megs but it's easier than combing through it. If you do want to comb through it and get only what you need, I suggest using this website: Installing a c++ compiler for windows
    2. Make your paths simple : Like user2359247 suggested.
    3. Finally run the create_android.bat, open your android project. Keep the path location of your build_native.sh file in mind and open your cygwin terminal.
    4. Navigate to the path in cygwin, and run the file with sh build_native.sh: At this point everything was quite smooth sailing.

    NOTE:

    Also I kept using my version of ndk which is r9 instead of r8 in the tutorial, it didn't give me any hiccups.

    Thank you SO!