Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GDNative library fails to load on M1 mac, "wrong architecture", regression #47355

Closed
Thoughtquake opened this issue Mar 25, 2021 · 5 comments
Closed

Comments

@Thoughtquake
Copy link

Godot version:
3.3.rc6.official

OS/device including version:
M1 Macbook Air (OSX 11.2.3)

Issue description:
When opening my project, which uses a GDNative library, the library fails to load with the following message:

"Can't open dynamic library: /Users/thoughtquake/Desktop/Dev/galacticchef/Godot/bin/osx/lib_galactic_chef.dylib, error: dlopen(/Users/thoughtquake/Desktop/Dev/galacticchef/Godot/bin/osx/lib_galactic_chef.dylib, 2): no suitable image found. Did find:
/Users/thoughtquake/Desktop/Dev/galacticchef/Godot/bin/osx/lib_galactic_chef.dylib: mach-o, but wrong architecture"

On the same machine, using the same build of my library, it works fine in Godot 3.2.3. I don't know if there are expected breaking changes that would require me to recompile my library with a different version of godot-cpp, but the "wrong architecture" part makes me think that's not the problem.

Steps to reproduce:

  1. Open the attached project on an M1 mac
  2. Observe errors in the Output pane

Note: I expect this project to crash if run; I just grabbed the library from a more complex project without doing anything to remove dependencies on things that aren't in this repro project. The point of this repro is whether or not the library is able to be loaded when opening the project.

Minimal reproduction project:
M1GDNativeRepro.zip

@Thoughtquake Thoughtquake changed the title GDNative library failes to load on M1 mac, "wrong architecture", regression GDNative library fails to load on M1 mac, "wrong architecture", regression Mar 25, 2021
@akien-mga
Copy link
Member

Most likely your GDNative library is compiled for x86_64 and not arm64. It works in 3.2.3 as that build is also compiled for x86_64 (so you're using it via Rosetta 2), while 3.3 RC 6 is a universal binary supporting both x86_64 and arm64.

@Thoughtquake
Copy link
Author

That makes sense - the library is indeed compiled for x86_64. If it's not expected to be able to load x86_64 libraries in the arm64 version of the engine, feel free to close this - apologies for the false alarm.

@akien-mga
Copy link
Member

Yeah that can't work, the architectures have to match. But I'll let @bruvzg comment before closing, maybe we can improve the usability somewhat to make things more obvious to users?

@bruvzg
Copy link
Member

bruvzg commented Mar 25, 2021

If it's not expected to be able to load x86_64 libraries in the arm64 version of the engine

This is definitely not supported, as it not supported by macOS, but you can run x86-64 version of the engine:

  • Right-click on the editor bundle in the "Finder".
  • Select "Get Info".
  • Check "Open using Rosetta".

Or you can build a universal version of GDNative library by applying this PR (godotengine/godot-cpp#529) to the godot-cpp source, and adding -arch x86_64 -arch arm64 to CCFLAGS and LINKFLAGS of your build config.

Also, since RC6 is signed and notarized, it will refuse to load the library that was downloaded and is not notarized as well. You'll need to remove "quarantine attribute" from the library first, see https://disable-gatekeeper.github.io/ for more details. The locally built library can be loaded without extra steps.

@Thoughtquake
Copy link
Author

Thanks for all the helpful tips!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants