Can't run cocos2d-x on M1 Chip

Hello everyone! I just get started to cocos2d-x but I have a problem. I’m following common steps to create a “Hello World” project. But I’m taking errors even if I try it on mac directory by “cmake …/… -GXcode” command or on ios directory by “cmake …/… -GXcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos” command.

If I try it on mac directory I take this error:

If try it on ios directory taking this error:

but when I change libz.dylib and libiconv.dylib or remove them, taking this error:

So, how can I run this? Thank you for your time :smiling_face_with_three_hearts:

MacOS Big Sur
Macbook Air M1 Chip
XCode 12.5.1
Cocos2d-x 4.0
Cmake 3.21.2

We don’t support the m1 chip at this time

1 Like

So, no way to work on M1 at the moment? Even for just practice on starter level? :slightly_frowning_face:

If there is a solution I’m not familiar with it. I don’t have an M1 to even work with.

1 Like

Alright then. Thank you for your time. :pray:t5::relaxed:

Cocos2dx (I use 3.17) works just fine on an M1 (my fat binary App is live in the Mac Appstore). No need for any adjustments, just make sure to link with M1 compiled dependencies (quite easy to find those online, compile yourself or use the ones from Cocos Builder). ARM libraries for iOS are not the ones to link to.

1 Like

Yes! 3.17 is works fine on M1. Thank you so much! :heart_eyes: :upside_down_face:

Hi @pinky2012
Can you please give detailed reply? Like what libraries need to reply and in which folder?
That will be great for lot of developers.

For any prebuilt library your app uses, you would need to find or create a “fat” library that contains both Intel and Apple silicon versions of the library (so the the libXXX.a files). There is nothing more to it really.

Which libraries and which folders depends heavily on your project and your cocos version. Most you can find in the Cocos2d/external folder. You’d have to replace all the Mac libraries (that you use and link against) with fat libraries also containing the Apple silicon build.

In my case I just started the build process (changed target to Intel + Apple Silicon) and I fixed (i.e. created or downloaded fat libraries) each error that I got. In some cases I just removed the dependency as I am not using it.

Most external libraries Cocos2d-x uses are also used by Cocos Creator. As Cocos Creator is Apple silicon compatible, most linker errors are solved by replacing your Cocos2d external dependencies for Mac with the ones from Cocos Creator (not just the lib files, also the header files. And if you do so , make sure you don’t mess up builds for other platforms).

I got my app to work within a few hours (and that was including making a version of the Nakama library for Apple Silicon that has tons of other dependencies as well).