Cross compile to ARM v5 running Linux

Hi,
I need to cross compile to ARM v5 running Linux.

I have Ubuntu 16.04 running in a VM with gcc-arm-linux-gnueabi and binutils-arm-linux-gnueabi installed.

$ sudo apt-get install gcc-arm-linux-gnueabi binutils-arm-linux-gnueabi
$ arm-linux-gnueabi-gcc --version
arm-linux-gnueabi-gcc (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.1) 5.4.0 20160609
$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/osboxes/golang/packages"
GORACE=""
GOROOT="/home/osboxes/golang/go"
GOTOOLDIR="/home/osboxes/golang/go/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build586862853=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
$ go version
go version go1.7.3 linux/amd64

Cross compilation command:

env CC=arm-linux-gnueabi-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=5 go build -o test

While running the app i get Error : x509: failed to load system roots and no roots provided

Only the cgo part is creating issues(running in a separate goroutine) and all other code runs perfectly fine.
I’m using github.com/eclipse/paho.mqtt.golang which depends on the crypto package.

I have validated my certs with openssl and getting some error there as well.

$ openssl s_client -showcerts -connect mqtt.some_uri.io:8883
CONNECTED(00000003)
...
verify error:num=19:self signed certificate in certificate chain
...

Any help is much appreciated. Thank you in advance.

Loading certificates on Linux doesn’t require cgo, however they must be in one of the expected locations.

Yup, save your time and avoid cross compile headaches, just make sure that the certificates are on disk in the usual place according to your distro and it will work. If not, please raise a bug (or just move the certs where Go expects them)

Fixed this by adding missing CA certs to /etc/ssl/certs. Thank you all.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.