chai2010 / webp

WebP decoder and encoder for Go (Zero Dependencies).
http://godoc.org/github.com/chai2010/webp
BSD 3-Clause "New" or "Revised" License
512 stars 89 forks source link

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

Open FTwOoO opened 4 years ago

FTwOoO commented 4 years ago

$ 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 commented 3 years ago

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 commented 3 years ago

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

prologic commented 3 years ago

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?