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

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

问题描述

我在Windows机器上安装了Go 1.2,编写了一个虚拟程序并设置了环境变量 GOARCH GOOS

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

  go build runtime:linux / amd64必须使用make.bat 
引导。 code>

这是什么意思?

解决方案



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

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

如果成功,那么您应该能够做到你所描述的(只使用amd64,而不是AMD64--它是区分大小写的)。

如果你的windows GOARCH是386,那么你需要先建立你的386工具。你需要为此下载mingw gcc。做什么user2714852说。



这里 https://golang.org/wiki/WindowsCrossCompiling 是类似的Linux指令,也许你会发现它们很有用。



Alex


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.

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

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

What does this mean?

解决方案

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

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

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

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.

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

Alex

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

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