Cross Compilation from Windows to Linux: A Step-by-Step Guide
For those seeking to cross-compile Go programs from a Windows environment to a Linux target, encountering the "runtime: linux/amd64 must be bootstrapped using make.bat" error can be puzzling. This message indicates that the necessary tools for cross-compilation have yet to be built.
To address this issue, you can utilize the following steps:
set GOARCH=amd64 set GOOS=linux
These commands set the target architecture to AMD64 and the target operating system to Linux.
go tool dist install -v pkg/runtime go install -v -a std
These commands will build the runtime tools and standard library for the specified target.
Ensure that the target architecture is set to "amd64" (all lowercase), as the commands are case-sensitive.
Alternatively, if your Windows GOARCH is 386, you will need to build 386 tools first, which requires downloading MinGW gcc. Refer to the instructions provided by user2714852 for this approach.
For further insights, consult the comprehensive Wiki page on Windows cross-compiling for Go: https://golang.org/wiki/WindowsCrossCompiling
The above is the detailed content of How to Cross-Compile Go Programs from Windows to Linux and Solve the 'runtime: linux/amd64 must be bootstrapped using make.bat' Error?. For more information, please follow other related articles on the PHP Chinese website!