Installing Clang++ compiler for Windows without Visual Studio


This page explains how to install Clang++ on your Windows machine without installing all of Visual Studio. You will still need to install either the "Visual Studio Build Tools for C++" (which gives you the Microsoft linker), or the MinGW (the alternative tools for C++ on Windows). Here, we're installing the former.

Installing the Build Tools

Go over to visualstudio.microsoft.com/downloads, scroll down all the way to the bottom (or click this if it is not outdated yet) and expand the box "Tools for Visual Studio 2019". From the options available, pick "Build Tools for Visual Studio 2019" and click the Download button; this should download an executable file that you will have to execute. This will install the build tools for you and prompt you to restart (which you can do after the next step).

Installing Clang++

Go to releases.llvm.org, click the "download" link on the latest version that is not "Current" (at the time of writing: 12.0.1) and go the github release page of that.

In this long list of files, you need to find the file "LLVM-<version>-win64.exe" (e.g. "LLVM-12.0.1-win64.exe"), download it and follow the steps (you probably want to select "Add LLVM to the system PATH for all users" under the install options).

Clang++ should now be installed on your machine, and you will probably have to restart the computer before everything is set up properly.

Using the compiler

If you want to compile a file called "Main.cpp", type the following in any terminal (with the current directory set to the directory that the file is in):

clang++ "./Main.cpp"
"./a.exe"

This should execute your C++ file. If it works, you have successfully installed the clang++ compiler on your Windows machine. Good luck!