以上是实例:
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o web.exe -ldflags "-H windowsgui" web.go 有时候会报 undefined: SQLiteConn接下来利用CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build -o web.exe -ldflags "-H windowsgui" web.go 会提示# runtime/cgogcc_libinit_windows.c:7:10: fatal error: 'windows.h' file not found这时候就用到了上面安装的MacPorts了CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC=/opt/local/bin/x86_64-w64-mingw32-gcc go build -o web.exe -ldflags "-H windowsgui" web.go
web.go是包含sqlite3的驱动的,这个是在mac下进行编译windwos碰到的问题。紧张是利用了交叉C编译器代替主机编译器。
https://github.com/mattn/go-sqlite3/issues/444
https://github.com/mattn/go-sqlite3/issues/372

github有人提问,办理方案便是利用c编译器代替主机编译器