How to cross compile from Windows to Linux?

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

Leave a Comment