r/C_Programming • u/maep • Sep 20 '26
Win32 development in Linux?
Does anyone here have practical experience with WIN32 development under Linux?
I just need the MSVC compiler and the Windows SDK. A full VM with Windows 11 and Visual Studio seems incredibly excessive for what should be just a few megabytes of compiler and headers.
13
Upvotes
37
u/wwabbbitt Sep 20 '26
You don't even need msvc compiler. mingw-w64-gcc works just fine.
You don't even need a VM to run and debug the executable, just use wine and winedbg
6
u/DawnOnTheEdge Sep 20 '26 edited Sep 20 '26
With the Windows SDK files, you can cross-compile using Clang and running natively. Clang with the
i686-pc-windows-msvctarget selected, the SDK files in its search path, and copies of the runtime libraries to link to, produces 32-bit binaries that link to the Windows system libraries (unlike MingW, which links to its own runtime library).2
u/Classic-Rate-5104 Sep 20 '26
I know older versions of MSVC run on wine but didn't try recently. Nowadays gcc cross compilation is easy
2
u/sciencekm Sep 20 '26
You can cross-compile with MinGW. You would still need Wine to run the exe or copy it a Windows machine.
Below is what it looks like on my Ubuntu on ARM v8. There is no Wine on this machine, so I simply ran "file" to show the properties of the Win32 executable.
1
u/catbrane Sep 29 '26
I help maintain a few cross-platform applications.
For convenience, all the binaries for all platforms are made on the same linux host running the same set of scripts. The windows binaries use mingw (patched to use clang) as the compiler. It makes a set of fully native executables (x64, x86, arm64, and on linux also glibc and musl).
IMO it's better than windows for building cross-platform software. If I were just targeting windows I'd probably use a win VM.
1
u/utahrd37 Oct 02 '26
Ugh, I’ve gone through this pain and found no great solution.
Best I found is spinning up a windows dev machine, creating a share and enabling WinRM.
On the Linux machine I mount the share to access the source code to do all my writing, and then WinRM with evil-WinRM to compile after loading the dev environment powershell script.
It is a long dumb process and I hope you find a better solution.
VS and VS code are awful to write in.
1
u/pedersenk Sep 20 '26 edited Sep 20 '26
Windows 7 SDK (~VS 2010) bundles a working cl toolchain.
Anything later and you need to go through the Visual Studio installer bloat and I don't think much of it is working (you may be able to rice things by extracting from a Windows install but its messy and amateur.)
gcc and clang (both MinGW-64) works well on wine.
Personally I would only recommend faffing with Microsoft's toolchain on wine if you *need* C++.NET extensions (e.g. cl /clr:pure). Its fairly decent tech but annoyingly single source vendor.
1
u/timrprobocom Sep 20 '26
What's the point? If you want to use Windows tools to develop and run Win32 programs, then use a VM. It's way more comfortable, and it's way less overhead than wine.
0
u/UltimaN3rd Sep 20 '26
I cross compile my C games with Zig. It bundles the Windows SDK and clang/llvm, etc. Of course, that's not MSVC, just letting you know that's the best way I've found for Linux->Windows cross compilation. I do the same for Linux -> MacOS, though that requires me to bring my own Apple SDK due to Apple's terms of use.
-5
u/Paul_Pedant Sep 20 '26
WIN32 is going to want to link to its own libraries. Why would you expect a Windows library to use the system calls implemented in the Linux kernel?