Skip to content

Compilers

This page mainly introduces the installation steps for various compilers/interpreters on different systems.

GCC

Windows

Manual Download and Installation

Visit the download page of MinGW-w64, which offers multiple build versions. For convenience, we use the build version provided by WinLibs.

First, go to WinLibs to download the latest installation package. Choose a suitable version; this tutorial selects GCC 12.3.0 + LLVM/Clang/LLD/LLDB 16.0.4 + MinGW-w64 11.0.0 (UCRT):

By default, LLVM Clang will be installed alongside. If you do not want to install it, you can choose the version on the right without LLVM/Clang/LLD/LLDB.

After downloading, extract it to a location on your computer. This tutorial extracts it to the root of the C drive. It is best to avoid non-English characters and spaces in the directory name, as they may cause issues later.

Next, we need to add the directory containing the compiler's executable files to the system environment variables, so that we don't need to specify the compiler path when compiling, making it more convenient to use. In the previous step, we extracted MinGW to the C:\mingw64 directory, so the directory containing the executable files is C:\mingw64\bin.

Press the Windows logo key + R, enter rundll32.exe sysdm.cpl,EditEnvironmentVariables to open the system environment variables settings window. In the "System Variables" section, select the variable named "Path", then click the "Edit" button:

In the edit window, click the "New" button on the right to add a new entry for the "Path" variable, and enter the directory containing the executable files recorded earlier (in this tutorial, C:\mingw64\bin).

Note for some older systems

Some older systems can only modify the variable value manually as text. In that case, you need to insert a half-width semicolon at the end of the variable value, then paste the directory containing the executable files after this half-width semicolon, as shown:

After completing, click the "OK" button all the way to exit.

Next, open a terminal, enter g++ --version and press Enter. If a prompt as shown appears, the installation is successful.

Scoop Installation

Open PowerShell and run the following script:

1
2
3
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
irm get.scoop.sh | iex
scoop install mingw-winlibs

Linux

Debian/Ubuntu

First, update the software package list:

1
sudo apt update

Then install directly using the command:

1
sudo apt install g++

Arch Linux

Install directly using the command:

1
sudo pacman -Syu gcc

openSUSE

Install directly using the command:

1
sudo zypper in gcc-c++

macOS

First, update the package manager:

1
2
brew upgrade
brew update

Then install directly using the command:

1
brew install gcc

JDK

There are many distributions of JDK. The following introduces two:

Python 3

There are many Python implementations1. Taking CPython 3 as an example, refer to Download Python | Python.org.

LLVM

Windows

Pitfalls of LLVM on Windows

Because LLVM lacks standard libraries on Windows, you still need to install MSVC or GCC.

Direct Installation

Visit the download page of LLVM and download LLVM-*-win64.exe.

If your network quality is poor, you can also visit 清华大学开源 software mirror site to download.

Open the .exe file, during installation check "Add LLVM to system PATH for current user", then keep clicking Next until installation completes.

Open a terminal, enter clang++ --version and press Enter. If something like

1
2
3
4
clang version 15.0.1
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: <omitted>

appears, it indicates success.

Scoop Installation

Open PowerShell and run the following script:

1
2
3
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
irm get.scoop.sh | iex
scoop install llvm

Linux

openSUSE

Install directly using the command:

1
sudo zypper in llvm clang

MSVC (Visual Studio)

Visit the Download Visual Studio page, find the "Download" section under "Community", and click "Free Download". After downloading, open the installer and select "Community 2022 Install". In the subsequently popped window, only select "Desktop development with C++", then click Install.

If you do not want to install the full Visual Studio, you can scroll down to the "All Downloads" section, find "Visual Studio Build Tools" under "Tools for Visual Studio", and click the "Download" behind it. After downloading, open the installer, follow the prompts to select "Desktop development with C++", then install. Alternatively, you can use the PortableBuildTools tool to install only the MSVC compiler.


  1. Alternative Python Implementations | Python.org ↩

  2. Eclipse Temurin is the former AdoptOpenJDK, which was transferred to the Eclipse Foundation in July 2021. For details, see this announcement. ↩