Cocos2d-x3.2 执行build_native.py 显示couldn't find the gcc toolchains

前端之家收集整理的这篇文章主要介绍了Cocos2d-x3.2 执行build_native.py 显示couldn't find the gcc toolchains前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

解决方案:

1.将ndk文件名称android-ndk-r10c修改为androidndkr10c 只要不带横线就可以

2.修改环境变量中的NDK_ROOT路径,去掉原来的横线

即由D:\cocos\android-ndk-r9d 修改为D:\cocos\androidndkr9d

分析如下:

用EditPlus打开build_native.py

def select_toolchain_version():
'''Because ndk-r8e uses gcc4.6 as default. gcc4.6 doesn't support c++11. So we should select gcc4.7 when
using ndk-r8e. But gcc4.7 is removed in ndk-r9,so we should determine whether gcc4.7 exist.
Conclution:
ndk-r8e -> use gcc4.7
ndk-r9 -> use gcc4.8
'''

ndk_root = check_environment_variables()
if os.path.isdir(os.path.join(ndk_root,"toolchains/arm-linux-androideabi-4.8")):
os.environ['NDK_TOOLCHAIN_VERSION'] = '4.8'
print "The Selected NDK toolchain version was 4.8 !"
elif os.path.isdir(os.path.join(ndk_root,"toolchains/arm-linux-androideabi-4.7")):
os.environ['NDK_TOOLCHAIN_VERSION'] = '4.7'
print "The Selected NDK toolchain version was 4.7 !"
else:
print "Couldn't find the gcc toolchain."

exit(1)


网上可能错误的解答.cocos2d-x3.2 只支持ndk r9. 因为ndkr10没有toolchains/arm-linux-androideabi-4.8"。其实ndkr10 到源文件看,什么都有,品类齐全。

网上正解:ndk_root不能有空格,是的。但是我检查了我的ndk_root没有空格啊。怎么办呢。。。焦急如焚。后来我想无论如何这个问题肯定是,python的os.path.isdir(os.path.join这两句无法读取我的NDK_ROOT。而我NDK解包的时候自动文件夹中生成了android-ndk-r10c这个文件夹,是不是'-'.也不能放在NDK_ROOT中。我将NDK_ROOT从F:\developer\software\androidNDK\android-ndk-r10c改为F:\developer\software\androidNDK\r10c。哈哈哈 系统显示The Selected NDK toolchain version was 4.8 !编译通过了~

原文链接:https://www.f2er.com/cocos2dx/342867.html

猜你在找的Cocos2d-x相关文章