Slide 37
Slide 37 text
Build ARM executable with Go
▪ x86_64 ホストで ARM の実行ファイルをクロスビルドする (Go言語を使用)
$ cat >hello.go
package main
import "fmt"
func main() { fmt.Println("hello, world") }
$ sudo apt install golang
$ GOARCH=arm go build hello.go
$ file hello
hello: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, Go
BuildID=r25mtH3xAmMqsN82YvTf/76iAXGVuGm9vmj6JX2uK/wp_gTuNYGed7ykVck7Ur/mSyuD7KUTU2imdNgD
NtQ, not stripped
$ ./hello
-bash: ./hello: cannot execute binary file: Exec format error
GOARCH=arm 指定で
ARMバイナリをビルド
x86_64 ホストでは
ARM バイナリは実行できない