You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cross compiling from macOS to linux and windows fails for me, due to gopackets libpcap bindings.
Maybe @notti can help?
Compile for Windows:
# install compiler toolchain and libpcap headers
$ brew install mingw-w64
$ brew install libpcap
$ GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CGO_ENABLED=1 CGO_CFLAGS="-I/usr/local/opt/libpcap/include" go build -o netcap-windows -i github.com/dreadl0ck/netcap/cmd
# github.com/google/gopacket/pcap
/usr/local/Cellar/mingw-w64/5.0.4_1/toolchain-x86_64/bin/x86_64-w64-mingw32-ld: cannot find -lwpcap
collect2: error: ld returned 1 exit status
Compile for Linux:
$ GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build -o netcap-linux -i github.com/dreadl0ck/netcap/cmd
# github.com/dreadl0ck/netcap/cmd
/usr/local/Cellar/go/1.11.4/libexec/pkg/tool/darwin_amd64/link: running clang failed: exit status 1
ld: warning: ignoring file /var/folders/3n/1r2xxfv55d35jxh33rklbzm80000gn/T/go-link-877356077/go.o, file was built for unsupported file format ( 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 ) which is not the architecture being linked (x86_64): /var/folders/3n/1r2xxfv55d35jxh33rklbzm80000gn/T/go-link-877356077/go.o
Undefined symbols for architecture x86_64:
"__cgo_topofstack", referenced from:
__cgo_f163a891a53f_Cfunc_calloc in 000001.o
__cgo_f163a891a53f_Cfunc_pcap_activate in 000001.o
__cgo_f163a891a53f_Cfunc_pcap_can_set_rfmon in 000001.o
__cgo_f163a891a53f_Cfunc_pcap_compile in 000001.o
__cgo_f163a891a53f_Cfunc_pcap_create in 000001.o
__cgo_f163a891a53f_Cfunc_pcap_datalink in 000001.o
__cgo_f163a891a53f_Cfunc_pcap_datalink_name_to_val in 000001.o
...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The text was updated successfully, but these errors were encountered:
Sorry for the late reply, but I was on winter holiday.
Hmm I don't have experience with cross-compiling cgo stuff. But I suspect one problem here will be the lines: https://github.com/google/gopacket/blob/6d81e5661bc8ae1efe3fbd78bd790daef871b489/pcap/pcap.go#L18-L20
For windows you would need the sdk for winpcap and then add the correct path to the ldflags.
With google/gopacket#568 you wouldn't need cgo for windows.
Not sure how to do the crosscompiling for linux. Maybe use travis-ci for building the linux-version?
Cross compiling from macOS to linux and windows fails for me, due to gopackets libpcap bindings.
Maybe @notti can help?
Compile for Windows:
Compile for Linux:
The text was updated successfully, but these errors were encountered: