Week 1: Starting Your C++ Adventure
Dive into the fundamentals of C++ and set up your development environment.
Explore Chapter 1Setting up Your Development Environment.
To write and run C++ code, you need a compiler and usually a code editor or an Integrated Development Environment (IDE).
1. Choosing a Compiler
A compiler translates your C++ source code into executable machine code.
- GCC (g++): Part of the GNU Compiler Collection, widely available on Linux and macOS (often via Xcode Command Line Tools), available on Windows (e.g., via MinGW or Cygwin).
- Clang: Another popular open-source compiler, known for fast compilation and helpful error messages. Often used alongside GCC or as part of LLVM.
- MSVC (Microsoft Visual C++): The compiler included with Visual Studio on Windows.
Installation varies by OS. On Linux, you can often install `g++` via your package manager (e.g., `sudo apt install build-essential` on Debian/Ubuntu). On macOS, installing Xcode Command Line Tools (`xcode-select --install` in Terminal) typically provides Clang/g++. On Windows, installing Visual Studio Community (with C++ workload) or setting up MinGW/MSYS2 are common choices.
2. Choosing a Code Editor/IDE
An IDE bundles an editor, compiler, debugger, and other tools.
- Visual Studio Code (VS Code): Free, popular, highly extensible. Requires installing C++ extensions (like Microsoft's C/C++ extension) and configuring it to use your chosen compiler.
- Visual Studio (Community Edition): Free for individuals and small teams on Windows. A full-featured IDE with excellent C++ support (uses MSVC compiler).
- CLion: Powerful cross-platform C++ IDE by JetBrains (paid, but often free for students).
- Code::Blocks: Free, open-source, cross-platform IDE.
- Simple Text Editors (like Sublime Text, Atom, Notepad++) + Manual Compilation: Possible, but less convenient for larger projects.
For beginners, VS Code (with configuration) or Visual Studio Community (on Windows) are often good starting points.