Lesson 4 +10 XP

Getting Started with a C++ Development Setup

Getting Started with a C++ Development Setup

You need exactly two things to start: an editor to type code and a compiler to turn it into a program.

The checklist

  • A text editor or a full IDE - where your .cpp files live.
  • A compiler - the tool that turns source into an executable.
  • (Optional but nice) a terminal to run and talk to your program.

Popular options

  • Visual Studio - a full Windows IDE. Editor, compiler, and debugger all in one.
  • Visual Studio Code - a lightweight editor. Add the C/C++ extension and a compiler like MinGW or Clang.
  • The command line - use a compiler such as g++ directly in a terminal.
  • On macOS: xcode-select --install gives you a C++ compiler.

Installing a compiler on Windows

  • Install the Visual Studio "Desktop development with C++" workload, or
  • Install MinGW and add g++ to your PATH.

Check the install by running g++ --version in a terminal. If it prints a version, you're ready.

Building from a terminal

g++ hello.cpp -o hello
  • g++ compiles (and links) the source file hello.cpp.
  • -o hello chooses the output executable name.
  • Run it: hello on Windows, or ./hello on macOS/Linux.

Inside an IDE

In Visual Studio or VS Code you simply hit "Build" or "Run". The IDE runs the compiler for you and shows the results in a console window.

TL;DR

  • You need an editor or IDE plus a compiler.
  • Visual Studio and VS Code plus a compiler are popular pairs.
  • g++ hello.cpp -o hello builds from the terminal.
  • Then run the program to see your result.