Cross compile with CGO_ENABLED for amd64 on arm64 ld: library not found for -lcrt0.o
Opened this issue · 0 comments
Bug Description
when compiling on macOS Ventura 13.6.3 with an m1 (arm) for a mac (x86) darwin/amd64 that requires CGO_ENABLED=1 env set
I receive this error; I've looked and search everywhere and can't find anything on why this would happen; if I run the same build command from the terminal it works without error.
/Users/<myuser>/go/pkg/tool/darwin_arm64/link: running clang failed: exit status 1 ld: library not found for -lcrt0.o clang: error: linker command failed with exit code 1 (use -v to see invocation)
What did you do?
GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 go build -tags '-ldflags -s -w -X "github.com/domainX/utils/version.GITCOMMIT=637b0a4-dirty" -X "github.com/domainX/utils/version.VERSION=" -X "github.com/domainX/utils/version.BUILDDATE=1706112416" -X "github.com/domainX/utils/version.GOVERSION=go1.21.6" -extldflags -static' -o /Volumes/990pro/STUFF/tclg/GitRepositories/personal/GoLang/src/github.com/domainX/examples/ex_mousemove/cross/mousemove-darwin-amd64/mousemove ./cmd/mousemove/.
What did you expect to happen?
Build to not error as it does on the terminal (iTerm2)
What actually happened?
ld library not found error
/Users/<myuser>/go/pkg/tool/darwin_arm64/link: running clang failed: exit status 1 ld: library not found for -lcrt0.o clang: error: linker command failed with exit code 1 (use -v to see invocation)
Environment
- Mage Version:
Mage Build Tool v1.15.0 Build Date: 2024-01-24T10:23:40-07:00 Commit: 9e91a03 built with: go1.21.6
- OS: [mac/arm64] Ventura 13.6.3