如何从 Windows 交叉编译到 Linux? [英] How to cross compile from Windows to Linux?

查看:78
本文介绍了如何从 Windows 交叉编译到 Linux?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在 Windows 机器上安装了 Go 1.2,编写了一个虚拟程序并将环境变量 GOARCHGOOS 分别设置为AMD64"和linux".

I've installed Go 1.2 on a Windows machine, wrote up a dummy program and set the environment variables GOARCH and GOOS to "AMD64" and "linux" respectively.

当我发出go build"命令时,我收到一个错误:

When i issue the "go build" command, i receive an error:

go build runtime: linux/amd64 must be bootstrapped using make.bat

这是什么意思?

推荐答案

它告诉您需要构建所有工具才能使用它们.

It tells you it needs all tools built before you can use them.

如果你的 windows GOARCH 是 amd64,那么你可以通过运行这个小批量程序来构建"所有需要的工具:

If your windows GOARCH is amd64, then you could "build" all required tools by running this small batch programs:

set GOARCH=amd64
set GOOS=linux
go tool dist install -v pkg/runtime
go install -v -a std

如果成功,那么您应该能够执行您所描述的操作(只需使用 amd64,而不是 AMD64 - 区分大小写).

If that succeeds then you should be able to do what you've described (just use amd64, not AMD64 - it is case sensitive).

如果您的 windows GOARCH 是 386,那么您需要先构建 386 工具.您需要为此下载 mingw gcc.按照 user2714852 说的做.

If your windows GOARCH is 386, then you would need to build your 386 tools first. You would need to download mingw gcc for that. Do what user2714852 said.

这里 https://golang.org/wiki/WindowsCrossCompiling 是 linux 的类似说明,也许您觉得它们有帮助.

Here https://golang.org/wiki/WindowsCrossCompiling are similar instructions for linux, perhaps you find them helpful.

亚历克斯

这篇关于如何从 Windows 交叉编译到 Linux?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆