Thursday 30 June 2016

Compiling GO code for the BeagleBone Black

One thing I love about GO is that you can cross compile code for different platforms. 

The Ethereum Foundation use this feature to create developer releases of GETH (the ethereum node written in GO) to many platforms relatively quickly.

It also means that I do not need to wait ages for a slow processor like the Raspberry Pi 1 or the BeagleBone Black to make the build, I can do it from my MacBook.

I first learned how effortless it was from Audrey Lim's go-snap project

There are more details about cross compiling for ARM in the GoArm Wiki

So finally - to compile on Linux or a MacBook for the BBB*

# GOARCH=arm GOOS=linux GOARM=7 go build myBBBprogram.go

Once it has finished you should have a cross compiled executable. All you have to do is to transfer it to the BBB with scp or an sftp utility and you are in business!

*or on a PC if you really have to...

No comments:

Post a Comment