Remix.run Logo
xvilka 3 hours ago

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

jezek2 2 hours ago | parent | next [-]

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.

okanat 2 hours ago | parent [-]

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++.

jezek2 2 hours ago | parent [-]

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.

reactordev 24 minutes ago | parent [-]

yeah, you can get away with this now a days because Git itself installs 2/3rds of the things you need anyway. You just need to finish the job by getting the package and putting the binaries in your git folder. Bam! mingw64, clang, what ever cc you need. It all links to standard windows stuff because you have to tell the linker where your win32.lib is. But this is true no matter the compiler, it's just Visual Studio supplies this in some god awful Program Files path.

dwroberts 2 hours ago | parent | prev | next [-]

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?

okanat 2 hours ago | parent [-]

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.

reactordev 2 hours ago | parent | prev [-]

Just msys2 it all

delta_p_delta_x 2 hours ago | parent [-]

MSYS2 is horrible. It brings a massive runtime environment and is a bad idea to foist on users.

michaelsbradley an hour ago | parent [-]

Aren’t you thinking of Cygwin, or the MSYS2 shell (dev tooling)?

The Windows-native software you build with MSYS2 can be shipped to and run by users that don’t have anything of MSYS2 installed.

reactordev an hour ago | parent [-]

He must be thinking of Cygwin as half of this is installed when you install git ;) Git Bash, etc…

okanat 12 minutes ago | parent [-]

MSYS2 is repacked Cygwin though. It is literally the same codebase compiled with slightly different flags. You need a full Unix environment for Bash to run, not just Mingw toolchain. The difference is Cygwin aims to create a full Unix system while MSYS2 just enough development environment to run bash, make etc to build native Windows programs with Mingw.

Git installs its own Mingw and Msys2 stuff but mostly compiled for a Mingw environment so they consume Windows paths natively instead of using MSYS2/Cygwin path conversion. That's why when you have mixed PATH variable all hell breaks loose with Git.