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

Mac下编译不了linux的binary? #30

Open
FTwOoO opened this issue Jun 11, 2020 · 3 comments
Open

Mac下编译不了linux的binary? #30

FTwOoO opened this issue Jun 11, 2020 · 3 comments

Comments

@FTwOoO
Copy link

FTwOoO commented Jun 11, 2020

$ 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)

@prologic
Copy link

I can confirm I run into this as well:

prologic@Jamess-iMac
Mon Aug 31 09:33:03
~/Projects/jointwt/twtxt
 (master) 2
$ CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build ./cmd/twtd/...
# github.com/prologic/twtxt/cmd/twtd
/usr/local/Cellar/go/1.14.6/libexec/pkg/tool/darwin_amd64/link: running clang failed: exit status 1
ld: warning: ignoring file /var/folders/8h/c9gl4gms3fjb0kyf7nb42ybh0000gn/T/go-link-693526846/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 000006.o
      __cgo_9b69751600cf_Cfunc_webpDecodeGray in 000006.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)

@yuhang2
Copy link

yuhang2 commented Aug 31, 2020

Build your code in linux, it could be more easy.

@prologic
Copy link

prologic commented Sep 1, 2020

Build your code in linux, it could be more easy.

That really defeats the point of cross-compiilation :) I primarily to dev on an Mac. I could do the release from Linux via Github Workflow actions and runner I suppose. Is there no way we can fix this in this codebase?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants