Skip to content

Getting Started

  1. Review the syllabus.
  2. Access the textbook (Chapter 1 for the first week).
  3. Set up the required software.
  4. Say "hi" to your instructor.

Instructors

Dr. Sean T. Hayes

Dr. Sean T. Hayes

Professor

Prof. Julie Henderson

Prof. Julie Henderson

Professor

Visual Studio Code

To program in C++, you will need a text editor and a compiler. For a text editor, we will use Visual Studio Code. For a compiler, we will use g++ from the GNU Compiler Collection (GCC). Follow the instructions below to setup both.

Visual Studio Code is an excellent text editor that works in macOS and Windows, is accessible from the command line, and has a great dark color scheme by default.

These small changes will make it easier to properly format your code.

  1. After installing Visual Studio Code, open it.

  2. Press Ctrl + Shift + P (or Cmd + Shift + P on a Mac) to open the Command Pallet.

  3. Type Settings (JSON) in the textbox and click on the dropdown as shown here.

  4. On the left, you see all of the default settings. On the right, you can add your own.

  5. Add these two settings. You can replace the existing values or add these fore the existing values (inside the curly brackets).

    json
    {
    	"editor.insertSpaces": false,
    	"editor.rulers": [80],
    	"editor.renderWhitespace": "boundary",
    	"editor.guides.bracketPairs": true,
    	"editor.bracketPairColorization.enabled": true,
    }

MacOS: Launching VS Code from the command line

On a Mac, you will need to perform the following steps to run VS Code from the terminal:

  1. Launch VS Code.
  2. Open the Command Palette (⇧⌘P i.e., Cmd+Shift+P) and type shell command to find the Shell Command: Install 'code' command in PATH command.
    Add Shell Command
  3. Restart the terminal for the new $PATH value to take effect. You'll be able to type code . in any folder to start editing files in that folder.

The g++ Compiler

  • GCC (GNU Compiler Collection)
    • 100% free software
    • Known as the Linux compiler, but cross platform
    • g++ is the GCC C++ Compiler

Complete one of the sets of instructions below depending of if your computer that runs Windows or macOS.

Installing G++ in Windows

On Windows, we will use the MinGW-w64 to compile C++ programs using g++.

  • MinGW (Minimalist GNU for Windows)
    • Includes GCC
    • MinGW-w64 is an updated branch of MinGW

Download the following:

Follow the following video instructions to set up your system.

Installing G++ on Apple Silicon (M1, M2, M3) Macs
  • The default C++ compiler for macOS is clang, which is similar but now what we are using in this course.
  • Installing GNU’s g++ compiler (GCC) has become a lot easier.
  1. Install Homebrew by opening the “Terminal” and pasting in the following command.
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

  2. Use Homebrew to install the GCC compiler with the following Terminal command.

  3. Go to where GCC was installed in the Terminal by typing:
    cd /opt/homebrew/bin

  4. Add a link to g++-14 to g++ by typing:
    ln -s g++-14 g++

    WARNING

    The path may be different as new versions are released. If the above command does not work, type ls to see what number you should use instead of 14 in the above command.

  5. Sign out and sign back into your computer.

Installing G++ on Intel-Based Macs
  • The default C++ compiler for macOS is clang, which is similar but now what we are using in this course.
  • Installing GNU’s g++ compiler (GCC) has become a lot easier.

Installation Steps:

  1. Install Homebrew by opening the “Terminal” and pasting in the following command.
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

  2. Use Homebrew to install the GCC compiler with the following Terminal command.
    brew install gcc

  3. Go to where GCC was installed in the Terminal by typing:
    cd /usr/local/bin/

  4. Add a link to g++-14 to g++ by typing:
    ln -s g++-14 g++

    WARNING

    The path may be different as new versions are released. If the above command does not work, type ls to see what number you should use instead of 14 in the above command.

  5. Sign out and sign back into your computer.

Using the Lab Computers

You may log into the lab computers with your personal account.

  • Username: Combine your First Initial, Middle Initial, and Last Name* (like the beginning of your CSU email address).
    For example, JDSmith
  • Password: Change1stTime!

There is a “special” Window’s command-line interface installed that includes MinGW-w64.

  • From the start menu (or the search), start typing “MinGW”.
  • Right click on “Run terminal” and select “Pin to Start” for easy access in the future.
  • Open “Run terminal” to access the CLI that includes our compiler.
  • Do NOT pin it to the taskbar.