r/cpp • • Mar 01 '23

[Q] Windows: non-MSVC Toolchains

I'm unsure what the "best" C++ compilers (ease of installation, updateability usability, supported C++ standard, code perf.) are on current Windows systems, not counting MSVC. MSys, MinGW, Gygwin, etc. ...

0 Upvotes

26 comments sorted by

22

u/Trider12 Mar 01 '23

Clang. It's even available as an option in Visual Studio.

6

u/kalmoc Mar 01 '23

The native windows clang toolchain stil needs the msvc standard library. Correct?

9

u/Trider12 Mar 01 '23

Yes. It uses MSVC runtime to be compatible with MSVC built libraries/applications.

17

u/sparkyParr0t Mar 01 '23

Do not forget that the microsoft stl (publicly available on github) is far more advanced in features and performances than what you get on other platforms (libstdc++...). You have whole teams well paid and dedicated full time to implement last c++ drafts.

15

u/Ameisen vemips, avr, rendering, systems Mar 01 '23

I was under the impression that they were all avatars of /u/stl that had become sentient and entities in their own right.

26

u/STL MSVC STL Dev Mar 01 '23

I AM INFINITY.

-1

u/eternalphane Mar 02 '23

Caz chair of WG21 is from MS

4

u/KingAggressive1498 Mar 01 '23

all the modern windows toolchains use msvc standard C libraries, even the mingw ones. That's why msys2 offers both ucrt and msvcrt variants of mingw-w64-gcc and mingw-w64-clang.

They do use their own C++ standard library implementations though (not sure about the Clang that ships with Visual Studio though)

1

u/Godworrior Mar 01 '23

I think it uses the MSVC linker as well?

1

u/bsdooby Mar 01 '23

Forgot clang; how easy is it to install? Using chocolatey, or other Windows package managers? Is a standalone installer better?

9

u/TheThiefMaster C++latest fanatic (and game dev) Mar 01 '23

It's on the Winget package manager (the official application package manager for Windows) as LLVM. It's probably on others too, but keep in mind it may be listed as LLVM rather than Clang for some reason.

Or you can just download the installer (LLVM-15.0.7-win64.exe).

Note you will also need the Windows SDK. I haven't looked to see if that's on a package manager, and I don't know if it includes the MS STL or you have to install that too.

I just normally install the lot via the Visual Studio installer (not VS Code). VS 2022 is actually really good.

3

u/n4jm4 Mar 01 '23

That's a common pattern: UNIX distributions package the compiler as "clang" half the time, "llvm" the other half of the time.

For people interested in cross-platform development, the inconsistency in package composition and naming is one more unnecessary inconvenience to manage.

2

u/Ameisen vemips, avr, rendering, systems Mar 08 '23

Sometimes they package it as both.

3

u/Trider12 Mar 01 '23

I installed it via Visual Studio Installer, because I already had it on my system. Other options might be available, but I haven't personally tried them.

2

u/RennyLeal Mar 02 '23

Check this https://blog.conan.io/2022/10/13/Different-flavors-Clang-compiler-Windows.html

"Conclusions The Cygwin Clang has been overwhelmingly replaced by the Msys2 flavors for this reason we are suggesting starting new efforts using the other flavors.

To decide between the MSVC based Clang flavors (LLVM/Clang and Visual Studio ClangCL) and the Msys2 based ones, the decision should be made depending on the other project constraints. In general the MSVC based Clang provides better compatibility with other Windows binary libraries and the system in general, while using the Msys2 subsystem flavor can work better if there are some other dependencies that heavily rely on GNU tools and wouldn’t work well with the MSVC compiler.

Between Msys2 Clang and Msys2 MinGW Clang, the decision should be made similarly. If there are other dependencies of the project that rely on libstdc++ runtime that have to play together, Msys2 MinGW Clang is probably the way to go, but otherwise, it seems that Msys2 Clang with libc++ could be the way to go.

In MSVC-based Clang, between LLVM/Clang and Visual Studio ClangCL, the final decision is probably the IDE. If a lot of development happens on Windows and developers want to use Visual Studio IDE, then the Visual Studio ClangCL will be better. If on the contrary most development happens in Linux, and Windows devs are happy with VS Code editor and using Ninja (which many developers love because of it being very fast), then LLVM/Clang could be a better choice."

1

u/bsdooby Mar 03 '23

Need to digest your answer ;)

1

u/Ameisen vemips, avr, rendering, systems Mar 08 '23

I need to spend more time getting the JVM build scripts working with msys2.

10

u/TimJoijers Mar 01 '23

clang is good. Avoid mingw because linking can be very, very slow with it. My hobby project builds in 2 minutes on other compilers, mingw spends 30 minutes linking.

3

u/KingAggressive1498 Mar 01 '23

msvc will give you the easiest time if you have to build any dependencies from source, because Cmake and boost.build and Windows batch files want to use Visual C++ by default on Windows. Unix makefiles tend to be iffy as far as working with mingw32-make as well, and for autotools based build scripts you need a unix-like shell (ie msys2)

Also while I have many minor greivances with Visual Studio that lead me to prefer another IDE, in terms of feature set its really the best free (via community edition) IDE on Windows.

If you decide to use mingw anyway, I strongly recommend you just go get msys2 and get your mingw installation through their package manager (which also includes binaries and development files for most major open source libraries, making your life easier). Most other mingw distributions are at least a few years out of date in terms of compiler version.

4

u/vickoza Mar 01 '23

I would agree with LLVM\Clang is the best C++ toolchain on Windows besides MSVC only thing is that you might not have full C++20/23 support especially for the standard library.

2

u/InjAnnuity_1 Mar 01 '23

There's also Embarcadero, a full IDE and toolchain, with the ability to use most of the many Delphi (Pascal) libraries. It uses an older version of Clang, modified to support a few extensions needed to produce code that can link with those libraries. I've found it straightforward to use and install.

In one developer's experience, the debugger can get confused. I suspect it's because they've created large namespaces, and #included files with unusual filename extensions.

2

u/catcat202X Mar 02 '23

No one here speaks of the Orange C++ toolchain 😿 https://github.com/LADSoft/OrangeC

3

u/firkinblood Mar 01 '23

I'm using w64devkit mingw. I still have to support Windows 7 and XP targets. I use msys2 for my primary dev setup, but w64devkit for a more controlled release build.

1

u/n4jm4 Mar 01 '23

clang-cl, or clang in WSL

1

u/RennyLeal Mar 02 '23

Check this https://blog.conan.io/2022/10/13/Different-flavors-Clang-compiler-Windows.html

"Conclusions The Cygwin Clang has been overwhelmingly replaced by the Msys2 flavors for this reason we are suggesting starting new efforts using the other flavors.

To decide between the MSVC based Clang flavors (LLVM/Clang and Visual Studio ClangCL) and the Msys2 based ones, the decision should be made depending on the other project constraints. In general the MSVC based Clang provides better compatibility with other Windows binary libraries and the system in general, while using the Msys2 subsystem flavor can work better if there are some other dependencies that heavily rely on GNU tools and wouldn’t work well with the MSVC compiler.

Between Msys2 Clang and Msys2 MinGW Clang, the decision should be made similarly. If there are other dependencies of the project that rely on libstdc++ runtime that have to play together, Msys2 MinGW Clang is probably the way to go, but otherwise, it seems that Msys2 Clang with libc++ could be the way to go.

In MSVC-based Clang, between LLVM/Clang and Visual Studio ClangCL, the final decision is probably the IDE. If a lot of development happens on Windows and developers want to use Visual Studio IDE, then the Visual Studio ClangCL will be better. If on the contrary most development happens in Linux, and Windows devs are happy with VS Code editor and using Ninja (which many developers love because of it being very fast), then LLVM/Clang could be a better choice."