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 compiling for ARM6 on x64 gives strange depdenency problems #39447

Closed
nuschpl opened this issue Jun 7, 2020 · 2 comments
Closed

Cross compiling for ARM6 on x64 gives strange depdenency problems #39447

nuschpl opened this issue Jun 7, 2020 · 2 comments

Comments

@nuschpl
Copy link

@nuschpl nuschpl commented Jun 7, 2020

I'm trying to compile https://github.com/bettercap/bettercap by cloning git repo and running:

$ env GOOS=linux GOARCH=arm GOARM=6 go get 
# github.com/google/gopacket/pcap
/usr/local/go/bin/pkg/mod/github.com/google/gopacket@v1.1.17/pcap/pcap.go:30:22: undefined: pcapErrorNotActivated
/usr/local/go/bin/pkg/mod/github.com/google/gopacket@v1.1.17/pcap/pcap.go:52:17: undefined: pcapTPtr
/usr/local/go/bin/pkg/mod/github.com/google/gopacket@v1.1.17/pcap/pcap.go:64:10: undefined: pcapPkthdr
/usr/local/go/bin/pkg/mod/github.com/google/gopacket@v1.1.17/pcap/pcap.go:102:7: undefined: pcapBpfProgram
/usr/local/go/bin/pkg/mod/github.com/google/gopacket@v1.1.17/pcap/pcap.go:103:7: undefined: pcapPkthdr
/usr/local/go/bin/pkg/mod/github.com/google/gopacket@v1.1.17/pcap/pcap.go:261:33: undefined: pcapErrorActivated
/usr/local/go/bin/pkg/mod/github.com/google/gopacket@v1.1.17/pcap/pcap.go:262:33: undefined: pcapWarningPromisc
/usr/local/go/bin/pkg/mod/github.com/google/gopacket@v1.1.17/pcap/pcap.go:263:33: undefined: pcapErrorNoSuchDevice
/usr/local/go/bin/pkg/mod/github.com/google/gopacket@v1.1.17/pcap/pcap.go:264:33: undefined: pcapErrorDenied
/usr/local/go/bin/pkg/mod/github.com/google/gopacket@v1.1.17/pcap/pcap.go:265:33: undefined: pcapErrorNotUp
/usr/local/go/bin/pkg/mod/github.com/google/gopacket@v1.1.17/pcap/pcap.go:265:33: too many errors
# github.com/google/gousb
/usr/local/go/bin/pkg/mod/github.com/google/gousb@v0.0.0-20190812193832-18f4c1d8a750/config.go:40:11: undefined: Milliamperes
/usr/local/go/bin/pkg/mod/github.com/google/gousb@v0.0.0-20190812193832-18f4c1d8a750/device.go:83:10: undefined: libusbDevHandle
/usr/local/go/bin/pkg/mod/github.com/google/gousb@v0.0.0-20190812193832-18f4c1d8a750/endpoint.go:45:12: undefined: EndpointDirection
/usr/local/go/bin/pkg/mod/github.com/google/gousb@v0.0.0-20190812193832-18f4c1d8a750/endpoint.go:49:15: undefined: TransferType
/usr/local/go/bin/pkg/mod/github.com/google/gousb@v0.0.0-20190812193832-18f4c1d8a750/endpoint.go:55:14: undefined: IsoSyncType
/usr/local/go/bin/pkg/mod/github.com/google/gousb@v0.0.0-20190812193832-18f4c1d8a750/endpoint.go:57:12: undefined: UsageType
/usr/local/go/bin/pkg/mod/github.com/google/gousb@v0.0.0-20190812193832-18f4c1d8a750/interface.go:47:8: undefined: Class
/usr/local/go/bin/pkg/mod/github.com/google/gousb@v0.0.0-20190812193832-18f4c1d8a750/interface.go:49:11: undefined: Class
/usr/local/go/bin/pkg/mod/github.com/google/gousb@v0.0.0-20190812193832-18f4c1d8a750/interface.go:51:11: undefined: Protocol
/usr/local/go/bin/pkg/mod/github.com/google/gousb@v0.0.0-20190812193832-18f4c1d8a750/usb.go:130:10: undefined: libusbContext
/usr/local/go/bin/pkg/mod/github.com/google/gousb@v0.0.0-20190812193832-18f4c1d8a750/usb.go:130:10: too many errors
$ go version
go version go1.14.4 linux/amd64

Those error seems to be connected with bettercap dependencies but I do have e.g libpcap-dev installed(for amd64 not arm) and I'm able to launch the same command successfully without GOARCH defined. Even If I should put those libraries in ARM version I'm not sure how to do this without breaking my host system.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/nusch/.cache/go-build"
GOENV="/home/nusch/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/usr/local/go/bin"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/tmp/bb/bettercap/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build056462439=/tmp/go-build -gno-record-gcc-switches"
@davecheney
Copy link
Contributor

@davecheney davecheney commented Jun 7, 2020

This is because cgo is disabled when cross compiling. Try with CGO_ENABLED=1 to force cgo, but this will likely fail as it will require a c cross compiler installed on your system.

@toothrot
Copy link
Contributor

@toothrot toothrot commented Jun 8, 2020

Closing, and seconding @davecheney's advice.

If you have further questions, see one of our forums: https://golang.org/wiki/Questions.

@toothrot toothrot closed this Jun 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.