← Back to context

Comment by xvilka

10 days ago

Clang is the better alternative to MinGW because it can use standard Windows libraries and avoids the need for additional runtime.

Can you actually do cross compilation (on Linux host to win64 binary) with clang in the same way as MingW does out of the box though?

  • No. You cannot even do direct compilation on the same host and target with clang only.

    LLVM doesn't come with the C library headers (VCRuntime) or the executable runtime startup code (VCStartup).Both of which are under Visual Studio proprietary licenses. So to use Clang on Windows without Mingw, you need Visual Studio.

I use MingW without any extra libs (no msys), it just uses the ancient msvcrt.dll that is present in all Windows versions, so my programs work even on Windows 2000.

Additionally the cross-compiler on Linux also produces binaries with no extra runtime requirements.

  • You can use Mingw-w64 UCRT or CLANG environments that come with MSYS2.

    Compared to older Mingw64 environments those link with the latest UCRT so you get almost the same style executable as Visual Studio.

    The only difference for C is that it uses Mingw exception handling and global initialization code, and it uses Itanium ABI for C++.

    • But that's the point, I don't want the same style executable as Visual Studio. Having to distribute bunch of DLLs and having worse compatibility is pretty bad.

      A major part of the incompatibility with older versions of Windows is just because newer VS runtimes cut the support artifically. That's it. Many programs would otherwise work as-is or with just a little help.

      1 reply →