Go/Golang Cross-Compile from Mac to Windows: fatal error: 'windows.h' file not found

最后都变了- 提交于 2019-12-01 14:39:36
OneOfOne

To enable cross-compiling for CGO you need to have a local toolchain that can compile C code for that target.

I'm not very familiar with Mac OS X, but on Arch Linux all I had to do was install mingw-w64-toolchain and compile my go code with:

env GOOS="windows" GOARCH="386"   CGO_ENABLED="1" CC="i686-w64-mingw32-gcc"   go build
// or to target win 64
env GOOS="windows" GOARCH="amd64" CGO_ENABLED="1" CC="x86_64-w64-mingw32-gcc" go build

On OSX, you can install mingw with homebrew: brew install mingw-w64

About the other error message though, ld: unknown option: --build-id=none seems like a bug, you might want to report that on the Go issue tracker.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!