bash
CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build -o buildOutput/windows ./...CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build -o buildOutput/windows ./...报错如下:
bash
# runtime/cgo
gcc_libinit_windows.c:6:10: fatal error: 'windows.h' file not found
make: *** [build-windows] Error 1# runtime/cgo
gcc_libinit_windows.c:6:10: fatal error: 'windows.h' file not found
make: *** [build-windows] Error 1解决方法:
bash
brew install mingw-w64brew install mingw-w64编译可执行文件,需要增加前缀:
CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++
参考:
https://www.mingw-w64.org/
https://www.dllhook.com/post/244.html
https://zsy619.github.io/golang/macos_go_etl_build/