FosterFramework / Foster

A small C# game framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

libFosterPlatform.dylib not built for Arm on macOS

luihabl opened this issue · comments

Hey, just wanted to report that I tried to run one of the samples (TinyLink) on macOS with M1 and I got an error where it looks like the platform lib is not built for arm. Not sure if the lib is meant to be built for that platform as well, but just wanted to point out.

The error that I got was:

Unhandled exception. System.DllNotFoundException: Unable to load shared library 'FosterPlatform' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: 
(...)
dlopen([path]/Foster/Samples/TinyLink/bin/Debug/net7.0/libFosterPlatform.dylib, 0x0001): tried:
'[path]/Foster/Samples/TinyLink/bin/Debug/net7.0/libFosterPlatform.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), 
'[path]/Foster/Samples/TinyLink/bin/Debug/net7.0/libFosterPlatform.dylib' (no such file), 
'[path]/Foster/Samples/TinyLink/bin/Debug/net7.0/libFosterPlatform.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))
(...)

As per this answer, maybe there is an easy solution by building a universal binary just setting CMAKE_OSX_ARCHITECTURES=arm64;x86_64 on the cmake file.

Hey! Yeah currently these are compiled with Github Actions, and my impression was that they didn't have Apple M1 runners yet, but it looks like they may have just added them a few days ago?

I don't think setting CMAKE_OSX_ARCHITECTURES=arm64;x86_64 will work if compiling from an intel MacOS, although I could be wrong?

Either way will need to investigate a bit and see if 1) we can just use the new Github Actions M1 runner or 2) if that CMake flag works from intel-based Macs... I unfortunately don't have an easy way to test this locally.

If you want to fix this locally until we can figure this out longer term you can compile the native library yourself if you have CMake installed.

I was just checking here and it seems that it's fine building for arm from an intel macOS (have a look here).

So I copied the repo and tried running the GitHub actions with that cmake option and it looks like it works - I downloaded and tested the artifact with the sample. If you think that's ok, I could open a PR after making some more tests, or at least it stays at some evidence for future fixes.

Oh cool! Yeah if that works then I am all for it! Happy to accept a pull request.

I'll have a chance to test this on my end tomorrow as well, but for now I assume this is resolved!

Ok! Let me know if it doesn't work for some reason, and I can investigate a bit more.

Awesome, sounds good! I appreciate the contribution, thanks for figuring it out! :)

No problem! And by the way, if you need any help fixing bugs or implementing new stuff in the future, let me know. I would be happy to spend some time contributing to a nice project like this.