golang 二进制在 mips 上不是 运行
golang binary not running on mips
我在 Windows10 上使用 Go 1.11.4,我想为 MIPS 74Kc 处理器 (Qualcomm Atheros QCA9558) 运行ning Linux 编译代码。我编译:
GOOS=linux GOARCH=mips go build
获取可执行文件,上传并 运行 它并获取:
Illegal instruction
再试一次 GOARCH=mipsle
得到:
./hello_mipsle_linux: line 1: syntax error: unexpected "("
我错过了什么?
要列出您当前构建工具链可用的所有可能的 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
所以可能是您还没有尝试过的剩余 GOARCH
排列之一,例如mips64
或 mips64le
.
uname -m
将有助于确定目标系统的机器架构。
我做构建的主机有一个 FPU,但板子没有。添加 GOMIPS=softfloat
修复它:
GOOS=linux GOARCH=mips GOMIPS=softfloat go build
我有类似的问题,通过设置 GOARCH=mipsle
解决了。这应该有效
GOOS=linux GOARCH=mipsle GOMIPS=softfloat go build
我的核心是MIPS 24KEc V5.0
,看我的博客https://zyfdegh.github.io/post/202002-go-compile-for-mips/
如果不行,请尝试这些步骤
- 通过
检查CPU架构,Big-Endian或Little-Endian
$ lscpu | grep "Byte Order"
cat /proc/cpuinfo
也会有帮助。
- 检查内核信息,mips 或 mips64,对我来说是 mips (32)
$ uname -a
Linux OpenWrt 4.14.151 #0 Tue Nov 5 14:12:18 2019 mips GNU/Linux
- 如果是Little-Endian,设置
GOARCH=mipsle
,如果是64bit Little-Endian,设置set GOARCH=mips64le
另一个相关问题Writing and Compiling Program For OpenWrt希望对您有所帮助。
我在 Windows10 上使用 Go 1.11.4,我想为 MIPS 74Kc 处理器 (Qualcomm Atheros QCA9558) 运行ning Linux 编译代码。我编译:
GOOS=linux GOARCH=mips go build
获取可执行文件,上传并 运行 它并获取:
Illegal instruction
再试一次 GOARCH=mipsle
得到:
./hello_mipsle_linux: line 1: syntax error: unexpected "("
我错过了什么?
要列出您当前构建工具链可用的所有可能的 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
所以可能是您还没有尝试过的剩余 GOARCH
排列之一,例如mips64
或 mips64le
.
uname -m
将有助于确定目标系统的机器架构。
我做构建的主机有一个 FPU,但板子没有。添加 GOMIPS=softfloat
修复它:
GOOS=linux GOARCH=mips GOMIPS=softfloat go build
我有类似的问题,通过设置 GOARCH=mipsle
解决了。这应该有效
GOOS=linux GOARCH=mipsle GOMIPS=softfloat go build
我的核心是MIPS 24KEc V5.0
,看我的博客https://zyfdegh.github.io/post/202002-go-compile-for-mips/
如果不行,请尝试这些步骤
- 通过 检查CPU架构,Big-Endian或Little-Endian
$ lscpu | grep "Byte Order"
cat /proc/cpuinfo
也会有帮助。
- 检查内核信息,mips 或 mips64,对我来说是 mips (32)
$ uname -a
Linux OpenWrt 4.14.151 #0 Tue Nov 5 14:12:18 2019 mips GNU/Linux
- 如果是Little-Endian,设置
GOARCH=mipsle
,如果是64bit Little-Endian,设置setGOARCH=mips64le
另一个相关问题Writing and Compiling Program For OpenWrt希望对您有所帮助。