c++ Compilation

c++ == g++

Compilation is translation from text to machine code.

c++ -std=c++11 -o hello_world hello_world.cpp




  • -std=c++11

Renaming the executable file:

c++ hello.cpp -o hello

Enable all warnings, treat them as errors:

  • -Wall
  • -Wextra
  • -Werror
g++ -Wall main.cpp -o main 

Optimization options:

  • -O0 no optimizations
  • -O3 or -Ofast full optimizations

Keep debugging symbols:

  • -g

Make object file:

g++ -c main.cpp -o main.o