cocos2dx的tojs是用来测试js绑定最好的范例。如果一上来马上执行genbindings.sh,几乎肯定会遇到这样的提示。
<severity = Fatal,
location = <SourceLocation file 'xx/tools/tojs/../../cocos2dx/platform/android\\CCPlatformDefine.h', line 4, column 10>,
details = "'android/log.h' file not found">
这种情况说明你的环境变量配置有问题。
在~/.bash_profile里面这样配置
# cocos2d-x
export DEVELOP_ROOT=${HOME}/develop
export COCOS2DX_ROOT=${DEVELOP_ROOT}/cocos2d-x
export COCOS2DX_CONSOLE_ROOT=${COCOS2DX_ROOT}/tools/cocos2d-console/console
#android
export ANDROID_ROOT=${DEVELOP_ROOT}/android
export ANDROID_SDK_ROOT=${ANDROID_ROOT}/sdk
export ANDROID_NDK_ROOT=${ANDROID_ROOT}/ndk
export NDK_ROOT=${ANDROID_NDK_ROOT}
export PATH=$PATH:$ANDROID_NDK_ROOT
export PATH=$PATH:$ANDROID_SDK_ROOT
export PATH=${PATH}:${ANDROID_SDK_ROOT}/platform-tools
#clangllvm
export CLANG_ROOT=${ANDROID_ROOT}/clang+llvm-3.1
这个是我的配置。其中必须要配置的是NDK_ROOT和CLANG_ROOT这两项