How to build a universal MachO library 'amd64+arm64' for MacOS? #31
Answered
by
jugglingjsons
jugglingjsons
asked this question in
Q&A
-
I am having issues with my export on macOS - not sure what I am doing wrong, I was wondering if we could have a working example as title says. |
Beta Was this translation helpful? Give feedback.
Answered by
jugglingjsons
Jul 1, 2024
Replies: 1 comment 8 replies
-
Are you trying to build for other platforms and architectures? ie. Windows and Linux from Mac. And/or are you having issues with exporting the project for Mac? |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You are correct. I've verified it over the weekend and using:(same versions run on intel mac and m1, build on m1)
env CGO_ENABLED=1 CGO_CFLAGS=-O3 GOARCH=amd64 go build -o darwin_amd64.dylib -buildmode=c-shared
and
env CGO_ENABLED=1 CGO_CFLAGS=-O3 GOARCH=arm64 go build -o darwin_amd64.dylib -buildmode=c-shared
and bundling it later on with :
lipo -create <pathToIntel.a> <pathToArm.a> -output <pathToUniversal.a>
Yields a working universal build.
If you're open to PRs, I will add that to the documentation with links as to why and such.