Binary was compiled with 'CGO_ENABLED=0'


(Georges Honore) #1

I have written some Go code which uses a sqlite driver which makes use of cgo.
This code compiles and runs on my Mac, when cross compiled for the BBB/ARM I get
the following: Binary was compiled with ‘CGO_ENABLED=0’
I looked this up and it is the result of setting the build to cross compile.
However, when I updated my Makefile with CGO_ENABLED=1 my project no longer
compiles, I get the message:
clang: error: argument unused during compilation: ‘-mno-thumb’ [-Werror,-Wunused-command-line-argument]
I am going to retry on a Linux platform, but if anybody has other suggestions.
Also will BBB/ARM platform require addition packages to run a Golang exe that uses cgo ?

Well I have resolved this problem, so in case this is of use to anybody else:
I tried setting up chaintool-ng, which I failed to get working on my Mac.
So then I took a differnt appraoch and
created a virtual linux machine, and downloaded a pre-built arm cross compiler.
I then got this to build the golang exe and it ran on my BBB/arm board.
Maybe not the best solution, but it fixed my problem.

It is unclear to me why “go build” can build a golang exe that cannot run.