We are trying to cross compile on Linux for Windows, but we got a “cannot find module for path” for some imported packages. Those packages are not “go modules”.
env GOOS=windows go build -x -v -o ourprogram WORK=/tmp/go-build503773516 build our.company/xxx/xxx: cannot find module for path github.com/xxx/xxx
I found why it is not working: we are using CGO and the files containing ‘import “C”’ are simply ignored. But the error message is not very helpful…
There is an open issue about that: https://github.com/golang/go/issues/24068
I installed mingw64-gcc and used the command: CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ GOOS=windows GOARCH=amd64 go build