We have already shown that you can install Clang in GNU/Linux distros without needing your package manager, as new versions often appears with features enabled that you wouldn’t want.
I’ve seen people report, for example, that their LSP that uses clangd
issues warnings for not using headers. Of course this can be disabled, but people like to have everything ready.
In this article we will see that you can install Clang/Clang++ on Windows with a single command.
In addition to having all the tools also available, such as:
clangd
;First make sure you don’t have clang
installed. Open PowerShell and run the command:
If the output that the term is not recognized (it is colored red).
The command below must be used in PowerShell.
When you paste, PowerShell will prompt you if you really want to paste, answer yes!
A drop-down menu will open informing you of the download progress and the entire installation process, just wait:
\bin
folderThe installation location will be similar to the path below, but in your case where it has [YOUR USER]
it must be the name of your Windows user:
Click on the address bar and copy this path.
After that, close PowerShell, or Windows Terminal, or even VSCode which uses a built-in terminal.
Now just open PowerShell again and note that the clang --version
command will already have output indicating the version!
Then just do a test and compile with clang
for C Language or Clang++ for C++ :
Inside the \bin
folder of the path you copied there will be an executable named g++
, of course it is not gcc/g++, but rather the clang++
renamed to g++
, same with gcc
.
If you have MinGW installed on your system, it will still work, as Windows will give priority for this binary, I think it might be the order it was added to the system variables.
But, just in case, it’s a good idea to test!