golang二进制文件未在mips上运行

时间:2019-03-14 02:40:14

标签: go mips

我在Windows 10上使用Go 1.11.4,我想为运行Linux的MIPS 74Kc处理器(Qualcomm Atheros QCA9558)编译代码。我编译:

GOOS=linux GOARCH=mips go build

获取可执行文件,上传并运行它并获取:

Illegal instruction

使用GOARCH=mipsle重试一次,然后获得:

./hello_mipsle_linux: line 1: syntax error: unexpected "("

我想念什么?

3 个答案:

答案 0 :(得分:1)

要列出当前构建工具链可用的所有可能的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排列之一,例如mips64mips64le

uname -m将有助于确定目标系统的计算机体系结构。

答案 1 :(得分:1)

我进行构建的主机有FPU,但董事会没有。这样就解决了:

GOOS=linux GOARCH=mips GOMIPS=softfloat go build

答案 2 :(得分:1)

我有一个类似的问题,可以通过设置init(onselecteditem : @escaping (Int) -> Void) { self.onSelectedItem = onselecteditem } 来解决。这应该工作

GOARCH=mipsle

我的核心是GOOS=linux GOARCH=mipsle GOMIPS=softfloat go build ,请参阅我的博客https://zyfdegh.github.io/post/202002-go-compile-for-mips/

如果还不行,请尝试以下步骤

  1. 通过以下方式检查CPU架构(大端或小端):
MIPS 24KEc V5.0

cat $ lscpu | grep "Byte Order" 也将有所帮助。

  1. 检查内核信息,mips或mips64,对我来说就是mips(32)
/proc/cpuinfo
  1. 如果是Little-Endian,则设置$ uname -a Linux OpenWrt 4.14.151 #0 Tue Nov 5 14:12:18 2019 mips GNU/Linux ;如果是64位Little-Endian,则设置set GOARCH=mipsle

另一个相关问题Writing and Compiling Program For OpenWrt希望对您有所帮助。

相关问题