Cannot find module for path when cross compiling

Hi,

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

The compilation is ok with GOOS=Linux on Linux…

Do you have any idea ?

Thanks
Regards,
Sylvain

Before going into cross compilation… Can you build natively on windows?

Yes it is working when building on Windows for Windows. (GOOS=windows)
But we have the same issue when building on Windows For Linux (GOOS=linux)

Nobody has an idea why it cannot find the package when Cross compiling?

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

and all is fine.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.