G++ is a compiler for C++ programs. Like GCC (its sister project), it can also compile C programs, but any programs with G++ will be compiled as C++ files.

To compile a C++ file, we can execute:

  1. g++ -std=c++11 -g –Wall hello.cpp –o hello
  2. ./hello

Flags

  • -Wall to enable warnings.
  • -g to compile in debug mode.
  • -std=c++xx to compile according to a certain language standard (for example, replace xx with 11).