2

I need to build a shared library in Go. For this purpose, I used CGO and then built SO lib with options

go build -o libUtil.so -buildmode=c-shared main.go

Now, I need to do the same, but for ARM architecture. When I do not use CGO, I only do export GOARCH=arm and this is enough to succeed. However, when I use CGO, I can not build SO library.

I suspect, that I need to install arm build tools, but I don`t know how to do that and how to configure my GO environment to use these tools. I hope, somebody might help me.

OS is Linux.

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189

1 Answers1

0

It may be different in you own *.nix system, but in common case your settings shoul de like below:

export CC=arm-linux-gnueabi-gcc //choose your arm compiler binary
export GOARCH=arm
export CGO_ENABLED=1

then you cab build:

go build -o yourLib.so -buildmode=c-shared main.go