Using WSL for cgo on Windows?

Is there any way to leverage the gcc compiler that is on a Linux distribution that is running on WSL or WSL2 when compiling from Windows?

I’m trying to compile a program from my Windows machine but it uses sqlite3 so I need a gcc compiler / suite. Most search results mention things like MinGW or TDM or Winsys. These seem like big fragile kitchen sinks to me, and with WSL sitting right there, why not leverage that?

One poster in this discussion mentions WSL but gives zero details:

I searched specifically for how to use WSL for cgo but I’m coming up empty. Am I missing something? Is this even a thing?

Note that my goal is to run my test suite in a Windows environment. So running the whole thing from within WSL defeats the purpose.

Self reply: My assumptions about gcc being able to cross compile to Windows from a Linux host (as I thought I could do using WSL as the host) were way off.

This article explains that if you want to do that you end up using MSYS2 for Debian. So basically gcc for Windows for Debian… :face_with_spiral_eyes::melting_face:

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