xgo
xgo copied to clipboard
Can’t Cross-Compile Go project with Xgo using CGO AMD=> ARM
HI ,
I’m working on go project that implmenting C code ! I can build the project on linux/amd64, and we now that go don’t cross compile if we use “IMPORT C”. So i work with XGO that maybe help me to cross compiling for ARM. i check XGO by cross compiling version of my go project without C code and it’s work like cross compil of go.
my environement :
go version go1.13.3 linux/amd64
Go env :
GO111MODULE="on"
GOARCH="amd64"
GOBIN="/opt/go/bin"
GOCACHE="/home/jj/.cache/go-build"
GOENV="/home/jj/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/opt/go"
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="/opt/go/src/github.com/brocaar/lora-app-server/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
My project is on =>
/opt/go/src/github.com/brocaar
My package that include c code is on =>
/opt/go/src/github.com/lorawan
the go.mode of my project :
module github.com/brocaar/lora-app-server
go 1.12
replace github.com/brocaar/lorawan => /opt/go/src/github.com/brocaar/lorawan
require (
cloud.google.com/go v0.44.3
github.com/Azure/azure-service-bus-go v0.9.1
github.com/NickBall/go-aes-key-wrap v0.0.0-20170929221519-1c3aa3e4dfc5
github.com/aws/aws-sdk-go v1.19.19
github.com/brocaar/loraserver v0.0.0-20190917115647-c4da45f52f2b
github.com/brocaar/lorawan v0.0.0-20190814113539-8eb2a8d6da09
github.com/dgrijalva/jwt-go v3.2.0+incompatible
)
the go.mode of my lorawan package :
module /opt/go/src/github.com/brocaar/lorawan
require (
github.com/NickBall/go-aes-key-wrap v0.0.0-20170929221519-1c3aa3e4dfc5
github.com/gopherjs/gopherjs v0.0.0-20190328170749-bb2674552d8f // indirect
github.com/jacobsa/crypto v0.0.0-20180924003735-d95898ceee07
github.com/jacobsa/oglematchers v0.0.0-20150720000706-141901ea67cd // indirect
github.com/jacobsa/oglemock v0.0.0-20150831005832-e94d794d06ff // indirect
)
go 1.13
My command to cross-compil is:
xgo -go 1.13.3 --targets=linux/arm-7 /opt/go/src/github.com/brocaar/lora-app-server/cmd/lora-app-server
The result error are :
src/github.com/brocaar/lora-app-server/cmd/lora-app-server
Checking docker installation... Client: Version: 18.09.7 API version: 1.39 Go version: go1.10.4 Git
commit: 2d0083d Built: Fri Aug 16 14:19:38 2019 OS/Arch: linux/amd64 Experimental: false
Server:
Engine:
Version: 18.09.7
API version: 1.39 (minimum version 1.12)
Go version: go1.10.4
Git commit: 2d0083d
Built: Thu Aug 15 15:12:41 2019
OS/Arch: linux/amd64
Experimental: false
Checking for required docker image karalabe/xgo-1.13.3... found.
Cross compiling github.com/brocaar/lora-app-server/cmd/lora-app-server...
Building locally github.com/brocaar/lora-app-server/cmd/lora-app-server...
Bootstrapping linux/arm-7...
go: github.com/brocaar/[email protected]: parsing
/opt/go/src/github.com/brocaar/lorawan/go.mod: open
/opt/go/src/github.com/brocaar/lorawan/go.mod: no such file or directory
2019/12/03 16:02:37 Failed to cross compile package: exit status 1.
the C code that my lorwan package use are in =>
/usr/local/go/src/crypto/lilliput
I already building the project with this configuration with go for amd64, i'm beginner on cross-compile, maybe there are some dependency i must configure or something like that.
I really don’t now why he say “no such file or directory”, because there are go.mod in folder lorawan ! can some one help me ? thanks
If your code is reachable somewhere (e.g. a zip bundle or something) I can try to repro. With no code to see what you're doing, I cannot repro and thus cannot figure out what might be off. Go modules are weird. In general xgo should work, but there's no explicit support, so might depend on your code base.
xgo isnt using go1.13 in his error.