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

Cross compile with CGO_ENABLED for amd64 on arm64 ld: library not found for -lcrt0.o #500

Open
gcstang opened this issue Jan 24, 2024 · 0 comments
Labels

Comments

@gcstang
Copy link

gcstang commented Jan 24, 2024

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant