While there is a massive number of IDEs support C++, not all of them are created equal. This guide is giving preference to the modern IDEs and/or the IDEs that you'll be most likely to use in your professional practice. They also happen to be the easiest to install on each respective platform:
Platform | Recommended IDEs |
---|---|
macOS | Xcode, Visual Studio Code |
Windows | Visual Studio Community, Visual Studio Code |
GNU/Linux | Visual Studio Code |
Similarly to the IDEs, there are typically several C++ compilers available for every major OS platform. We'll be using the "default" compiler for each platform — the one that's distributed by the operating system's vendor as a part of their IDE/development toolset:
Platform | Compiler | Installation |
---|---|---|
Mac | clang | Installed with Xcode; a standalone download is available here (you'll be asked to log in with your Apple ID; search for "command line tools" once in, make sure to sort the results by release date). |
Windows | Microsoft C/C++ compiler | Installed with Visual Studio; a standalone download is available here under Tools for Visual Studio 2019 > Build Tools for Visual Studio 2019. |
Linux | gcc | Included in all distribution; open a terminal and run sudo apt install build-essential if it's not installed by default. |
Most recent versions of the compilers listed above support all or most of the C++17 standard. You do have to explicitly enable C++17 support, though:
Compiler | Enabling C++17 support |
---|---|
clang, gcc | Add -std=c++17 to the compiler flags, e.g. clang++ -std=c++17 main.cpp . |
Microsoft C/C++ compiler | See How to enable C++17 compiling in Visual Studio, or manually add /std:c++17 to the compiler flags, e.g. cl /std:c++17 main.cpp . |
Xcode is Apple's IDE for developing on Mac. It supports C++ out-of-the-box and comes with Apple version of clang
compiler.
- Install Xcode.
- Install the command line tools by opening a terminal and running the following command:
xcode-select --instal
.
- Launch Xcode, in the Welcome dialog select Create a new Xcode project.
- In the project template dialog, choose macOS > Command Line Tool, then enter the project name, organization identifier (you can use your last name), and change the Language to C++.
- Select the location for your project (e.g. your home directory).
- In the Xcode menu, select Product > Build or press
⌘B
.
- In the Xcode menu, select Product > Run or press
⌘R
.
Visual Studio Community is a free edition of Microsoft Visual Studio, a commercial IDE from Microsoft. It supports C++ out-of-the-box and comes with Microsoft C/C++ compiler.
- Download and install Visual Studio Community.
- See Visual Studio's official documentation.
Visual Studio Code (VS Code) is a free, open source, customizable editor from Microsoft available on all major platforms. It includes first-class support for C++, including debugging, syntax highlighting, code completion, linting and refactoring. It also comes with a wealth of extensions that can be installed to further enhance the editor's functionality, effectively making it a full-fledged, extensible IDE.
-
Download and install VS Code.
-
Launch VS Code, click on the Extensions icon, search for and install all of the following extensions:
- C/C++ extension from Microsoft.
- Easy C++ projects from Alejandro Charte Luque.
- Catch2 and Google Test Explorer by Mate Pek.
- Open a new folder in VS Code.
- Open the command palette (
F1
) and search for "easy cpp", then select the Easy Cpp/C++: Create new C++ project option. - Select your target platform/architecture (e.g. [Clang++/LLDB] macOS ).
- Click "⚙️ Build" in the Status Bar at the bottom or press
⇧⌘B
.
- Click "▶ Build & Run" in the Status Bar at the bottom or press
F7
.
If you run into questions or problems while following this guide, please open a Github issue in this repo.