Home >Backend Development >Golang >How to Fix the 'runtime: linux/amd64 must be bootstrapped' Error During Go Cross-Compilation from Windows?

How to Fix the 'runtime: linux/amd64 must be bootstrapped' Error During Go Cross-Compilation from Windows?

Linda Hamilton
Linda HamiltonOriginal
2024-12-26 13:01:13176browse

How to Fix the

Cross-Compiling from Windows to Linux: Resolving the "runtime: linux/amd64 must be bootstrapped" Error

When attempting to cross-compile from Windows to Linux with Go 1.2, users may encounter an error indicating that "runtime: linux/amd64 must be bootstrapped using make.bat." This error essentially means that the necessary tools for cross-compilation have not yet been built.

To resolve this issue, follow these steps:

For Windows GOARCH amd64:

  1. Run the following batch commands:

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

For Windows GOARCH 386:

  1. Install MinGW GCC.
  2. Follow the instructions at https://golang.org/wiki/WindowsCrossCompiling to build the 386 tools.

Once the appropriate tools have been built, you should be able to successfully execute the "go build" command and cross-compile your Go program for Linux.

The above is the detailed content of How to Fix the 'runtime: linux/amd64 must be bootstrapped' Error During Go Cross-Compilation from Windows?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn