[英]golang binary not running on mips
I'm using Go 1.11.4 on Windows 10 and I want to compile code for a MIPS 74Kc processor (Qualcomm Atheros QCA9558) running Linux.我在 Windows 10 上使用 Go 1.11.4,我想为运行 Linux 的 MIPS 74Kc 处理器(Qualcomm Atheros QCA9558)编译代码。 I compile with:
我编译:
GOOS=linux GOARCH=mips go build
Get an executable, upload and run it and get:获取可执行文件,上传并运行它并获得:
Illegal instruction
Try again w/ GOARCH=mipsle
and get:用
GOARCH=mipsle
再试一次,得到:
./hello_mipsle_linux: line 1: syntax error: unexpected "("
What am I missing?我错过了什么?
My host doing the build had an FPU but the board does not.我的主机进行构建时有一个 FPU,但电路板没有。 Adding
GOMIPS=softfloat
fixed it:添加
GOMIPS=softfloat
修复它:
GOOS=linux GOARCH=mips GOMIPS=softfloat go build
To list all possible MIPS architects available to your current build toolchain, use the go tool
eg要列出当前构建工具链可用的所有可能的 MIPS 架构师,请使用
go tool
例如
$ go version
go version go1.12 darwin/amd64
$ go tool dist list | grep mips
linux/mips
linux/mips64
linux/mips64le
linux/mipsle
so probably one of the remaining GOARCH
permutations you have not tried eg mips64
or mips64le
.所以可能是您还没有尝试过的其余
GOARCH
排列之一,例如mips64
或mips64le
。
uname -m
would help to determine your target system's machine architecture. uname -m
将有助于确定您的目标系统的机器架构。
I have a similar issue and it's solved by setting GOARCH=mipsle
.我有一个类似的问题,它已通过设置
GOARCH=mipsle
解决。 This should work这应该工作
GOOS=linux GOARCH=mipsle GOMIPS=softfloat go build
My core is MIPS 24KEc V5.0
, see my blog https://zyfdegh.github.io/post/202002-go-compile-for-mips/我的核心是
MIPS 24KEc V5.0
,看我的博客https://zyfdegh.github.io/post/202002-go-compile-for-mips/
If it's not OK, try these steps如果不行,请尝试以下步骤
$ lscpu | grep "Byte Order"
cat /proc/cpuinfo
would also be helpful. cat
/proc/cpuinfo
也会有帮助。
$ uname -a
Linux OpenWrt 4.14.151 #0 Tue Nov 5 14:12:18 2019 mips GNU/Linux
GOARCH=mipsle
, if it's 64bit Little-Endian, set set GOARCH=mips64le
GOARCH=mipsle
,如果是 64bit Little-Endian,设置 set GOARCH=mips64le
Another related question Writing and Compiling Program For OpenWrt hope it helps.另一个相关问题为 OpenWrt 编写和编译程序希望它有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.