Loading lessons...
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
.cppfiles 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 --installgives 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 yourPATH.
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 filehello.cpp.-o hellochooses the output executable name.- Run it:
helloon Windows, or./helloon 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 hellobuilds from the terminal.- Then run the program to see your result.