Setting up a C++ Programming Environment

Tue Jan 28 2025
Updated: Fri Feb 07 2025
Facebook share linkTwitter/X share linkLinkedIn share linkReddit share linkReddit share link

Setting Up a C++ Programming Environment

When writing documents, most people use word processors like Microsoft Word or Google Docs. While these tools offer various stylistic options that make the text visually appealing for humans, they are not suitable for programming. Computers do not interpret formatting or visual styles; they only process the plain text commands provided within a file. Additionally, traditional word processors lack the essential tools required for programming. To write and execute code using such editors, you would need to rely on several additional programs, creating a fragmented workflow. Similarly, older coding methods, such as command-line text editors like EMACS or VIM, often require running multiple supplementary tools to accomplish the same tasks.

To simplify and streamline the programming process, Integrated Development Environments (IDEs) were created. An IDE is a software application that combines all the necessary tools for software development into one centralized platform. Using an IDE allows developers to write, test, debug, and manage code more efficiently. The main features of an IDE include:

  1. Code Editor: A specialized text editor designed for programming, equipped with syntax highlighting, code completion, and error detection to assist with writing code.
  2. Terminal: A built-in interface for executing system commands and interacting directly with the operating system.
  3. Compiler/Interpreter: Converts high-level source code into machine-readable code (binary) or executes it directly, depending on the programming language.
  4. Debugger: A tool for identifying and fixing errors in the code by enabling developers to step through the program, set breakpoints, and inspect variable states.
  5. Version Control Integration: Provides tools to manage code changes, track revisions, and collaborate with others, often integrating with version control systems like Git.

There are numerous IDEs available, but this blog will focus on using Visual Studio Code (VSC). Developed by Microsoft, Visual Studio Code is a lightweight and versatile IDE that supports programming in almost any language and works across all major operating systems. It is essential to distinguish Visual Studio Code from its more robust counterpart, Visual Studio. While Visual Studio is a feature-rich, paid IDE tailored for large-scale development, Visual Studio Code is free, accessible, and perfectly suited for learning to program.

You can download Visual Studio Code here. After downloading, run the installation to get started.


Next Steps: Installing the GCC Compiler

In order to turn high-level C++ code into machine code a computer can read a compiler will be needed (explained in a later post). Installing a compiler is different based on your machine.


MacOS Installation

  1. Open a new terminal window (search for terminal in the command+space menu or launch pad).
  2. Enter the command: xcode-select --install

Using xcode-select --install on the mac terminal to install xcode command line developer tools for C++ (GCC compiler).

  1. Wait for the prompt The command requires the command line developer tools. Would you like to install the tools now? and select Install.

Confirm install of command line developer tools for Mac.

  1. Wait for the installation to complete (will take a few minutes).

The install can be verified using the command g++ --version which should produce a message stating the version number (message will be OS dependent).


Windows Installation

(To be completed...)


Linux Installation

Most distributions come with the GCC compiler installed. If your version does not see it's documentation on how to download the GCC compiler.