Getting Started
Getting Started
Install a compiler, write your first program, and build from the command line.
Getting Started
Install a compiler, write your first program, and build from the command line.
Use one of these toolchains:
#include <iostream>
int main() {
std::cout << "Hello, C++!\n";
}
Save it as main.cpp.
g++ -std=c++23 -Wall -Wextra -pedantic main.cpp -o app
cl /std:c++23 /W4 main.cpp
./app
A C++ source file is compiled into machine code. The compiler checks syntax and types before you run the program.
As soon as you move past "hello world", prefer separate debug and release builds.
g++ -std=c++23 -Wall -Wextra -Wpedantic -g -O0 main.cpp -o app-debug
g++ -std=c++23 -Wall -Wextra -Wpedantic -O2 main.cpp -o app-release
The debug build helps investigation. The release build shows the performance and code generation you will eventually ship.
project/
src/
main.cpp
include/
build/
Start small, but keep generated files out of your source directories.