/cs3210-labs

Primary LanguageC++MIT LicenseMIT

C++ Tooling

Integrated Development Environments (IDEs)

While there is a massive number of IDEs support C++, not all of them are created equal. We'll be giving preference to the modern ones and/or the ones 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

Compilers

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).
Windows Microsoft C/C++ compiler Installed with Visual Studio; a standalone download is available here under Tools for Visual Studio 2017 > Build Tools for Visual Studio 2017.
Linux gcc Included in all distribution; open a terminal and run sudo apt install build-essential if it's not installed by default.

C++17 support

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

Xcode is Apple's IDE for developing on Mac. It supports C++ out-of-the-box and comes with Apple version of clang compiler.

Installation

  • Install Xcode.
  • Install the command line tools by opening a terminal and running the following command: xcode-select --instal.

Creating, building and running a project

Create a project

  • 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).

Build

  • In the Xcode menu, select Product > Build or press ⌘B.

Run

  • In the Xcode menu, select Product > Run or press ⌘R.

Visual Studio Community

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.

Installation

Creating, building and running a project

Visual Studio Code

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.

Installation

Creating, building and running a project

Create a project

  • 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 ).

Build

  • Click "⚙️ Build" in the Status Bar at the bottom or press ⇧⌘B.

Run

  • Click "▶ Build & Run" in the Status Bar at the bottom or press F7.

Questions/Problems?

If you run into questions or problems while following this guide, please open a Github issue in this repo, and we'll take it from there.