[cocos source code learning] Solve the problem of cocos2d-x-4.0 IOS build error - execute command error, return value: 65

insert image description here

build environment

Hardware: macbook pro quad-core Intel Core i7
System: macOS Big Sur 11.4.2, xcode Version 13.1, cmake 3.20.5
Software: iterm2 Build 3.4.8, zsh 5.8, python 2.7.16
cocos2d-x v4: official download package http://cocos2d-x.org/filedown/cocos2d-x-v4.0
insert image description here

PS: The official recommended configuration is as follows v4.0 environment requirements
insert image description here

build steps

Step 1: After parsing the zip package, enter the cocos2d-x-4.0 directory and execute the setup.py script
insert image description here
Step 2: Update the environment variables, and source the .zshrc file according to the prompt, that is, update the cocos-related environment variables and configuration to the current shell
insert image description here

Step 3: Use the cocos command to create an IOS Demo project (the Demo project copies the cocos source code in the current directory and creates an IOS APP Demo that depends on the source code)

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

insert image description here
Step 4: Enter the Demo directory, create a build folder, and CD to this folder (~/shell_temp/MyGame/build) and execute the following build command

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

Encounter problems

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

insert image description here
Seeing that ld is a link error, first check whether an IOS APP project is generated normally, open and compile it with xocde

find the reason

Go to the ios-build of the Demo project MyGame, we see MyGame.xcodeproj, that is, use xcode to open and compile to see the error situation
insert image description here
insert image description here

solution

/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/

insert image description here
The changed configuration is as follows
insert image description here
Build successfully and start Demo!
insert image description here

reference documents

Guess you like

Origin blog.csdn.net/SCHOLAR_II/article/details/127974588
Recommended