Search code examples
androidmacosbashcocos2d-x

How to setup cocos2x console tool path?


I setup cocos2d-x as outlines here: http://www.codeproject.com/Articles/801093/Writing-Games-with-Cplusplus-for-Android-on-a-Mac

Setup.py had all the expected output,

./setup.py

Setting up cocos2d-x... ->Check environment variable COCOS_CONSOLE_ROOT ->Search for environment variable COCOS_CONSOLE_ROOT... ->COCOS_CONSOLE_ROOT is found : /Users/john/Documents/Projects/Cocos2d/cocos2d-x-3.5/tools/cocos2d-console/bin

->Check environment variable COCOS_TEMPLATES_ROOT ->Search for environment variable COCOS_TEMPLATES_ROOT... ->COCOS_TEMPLATES_ROOT is found : /Users/john/Documents/Projects/Cocos2d/cocos2d-x-3.5/templates

->Configuration for Android platform only, you can also skip and manually edit "/Users/john/.bash_profile"

->Check environment variable NDK_ROOT ->Search for environment variable NDK_ROOT... ->NDK_ROOT is found : /Users/john/Documents/Projects/Android/android-ndk-r9d

->Check environment variable ANDROID_SDK_ROOT ->Search for environment variable ANDROID_SDK_ROOT... ->ANDROID_SDK_ROOT is found : /Users/john/Documents/Projects/Android/adt-bundle-mac-x86_64-20140321/sdk

->Check environment variable ANT_ROOT ->Search for environment variable ANT_ROOT... ->ANT_ROOT is found : /Users/john/Documents/Projects/ANT/apache-ant-1.9.4/bin

Please execute command: "source /Users/john/.bash_profile" to make added system variables take effect

but I cannot run cocos directly:

Eg: cocos

I always have to type the full path: Eg:

/Users/john/Documents/Projects/Cocos2d/cocos2d-x-3.5/tools/cocos2d-console/bin/cocos

As a result, I cannot run ./build_native.py etc for generating my android build because it errors out saying : sh: cocos: command not found

I ran the "source /Users/john/.bash_profile" command that setup.py said I should but it makes no difference.

How do I rectify this ?

(Cocos2dx 3.5)

EDIT:

When I type: "export" in the terminal, I cannot find any lines for setting the environment variables for:

NDK_ROOT
COCOS_CONSOLE_ROOT

How do I rectify this ?


Solution

  • I added cocos console root to the bash_profile manually.

    Here how I did :

    In Terminal, type:

    open ~/.bash_profile
    

    It will be opened within TextEdit. Add these lines :

    export COCOS_CONSOLE_ROOT=/Users/barisatamer/Documents/workspace-game/Engine_Source/cocos2d-x-3.4/tools/cocos2d-console/bin
    export PATH=$COCOS_CONSOLE_ROOT:$PATH