Mac下编译不了linux的binary?
- Dominant language
- Go
- Stars
- 723
- Forks
- 113
- PR merge metrics
- No merged PRs in 30d
Description
**$ CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build ./main.go**
\# command-line-arguments
/usr/local/go/pkg/tool/darwin_amd64/link: running clang failed: exit status 1
ld: warning: ignoring file /var/folders/m2/nwyl7pg57j378_k7qqfghmpw0000gn/T/go-link-956317668/go.o, building for macOS-x86_64 but attempting to link with file built for unknown-unsupported file format ( 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 )
Undefined symbols for architecture x86_64:
"__cgo_topofstack", referenced from:
__cgo_26061493d47f_C2func_getnameinfo in 000002.o
__cgo_26061493d47f_Cfunc_getnameinfo in 000002.o
__cgo_26061493d47f_C2func_getaddrinfo in 000004.o
__cgo_26061493d47f_Cfunc_gai_strerror in 000004.o
__cgo_26061493d47f_Cfunc_getaddrinfo in 000004.o
__cgo_9b69751600cf_Cfunc_WebPGetFeatures in 000018.o
__cgo_9b69751600cf_Cfunc_webpDecodeGray in 000018.o
...
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the ./main.go entry point and reproduce the reported CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build command on macOS. Inspect the Go linker and clang output to determine the cross-compilation failure; done means producing a working Linux amd64 binary from macOS.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- build-system, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100