【cocos源码学习】解决 cocos2d-x-4.0 IOS构建出错的问题—执行命令出错,返回值:65

在这里插入图片描述

构建环境

硬件:macbook pro 四核Intel Core i7
系统:macOS Big Sur 11.4.2、 xcode Version 13.1 、cmake 3.20.5
软件:iterm2 Build 3.4.8、zsh 5.8、python 2.7.16
cocos2d-x v4 : 官方下载压缩包 http://cocos2d-x.org/filedown/cocos2d-x-v4.0
在这里插入图片描述

PS:官方推荐配置如下 v4.0环境要求
在这里插入图片描述

构建步骤

第一步:解析zip包后,进cocos2d-x-4.0目录并执行setup.py脚本
在这里插入图片描述
第二步:更新环境变量,根据提示source一下.zshrc文件,即更新cocos相关的环境变量与配置到当前shell
在这里插入图片描述

第三步:使用cocos命令创建一个IOS Demo工程(Demo工程Copy了当前目录的cocos源码并创建了依赖源码的IOS APP Demo)

cocos new MyGame -p com.your_company.mygame -l cpp -d /Users/luogw/shell_temp/demo

在这里插入图片描述
第四步:进到Demo目录,创建一个build文件夹,并CD到该文件夹(~/shell_temp/MyGame/build)后执行该如下构建命令

cocos run --proj-dir .. -p ios

遇到问题

执行命令出错,返回值:65。

在这里插入图片描述
看到ld是链接出错了,先看一个是否正常生成了IOS APP项目,用xocde打开编译看一下

查找原因

到Demo工程 MyGame的ios-build,我们看到了 MyGame.xcodeproj,即用xcode打开编译看下出错的情况
在这里插入图片描述
在这里插入图片描述

解决方案

/usr/lib/libiconv.dylib 改成 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libiconv.dylib
/usr/lib/libz.dylib 改成 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libz.dylib

即两个库的路径加上 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/

在这里插入图片描述
更改后的配置如下
在这里插入图片描述
构建成功并启动Demo!
在这里插入图片描述

参考文档

猜你喜欢

转载自blog.csdn.net/SCHOLAR_II/article/details/127974588
今日推荐