g++
GNU C++ compiler
TLDR
Compile C++ file
$ g++ [source.cpp] -o [output]
Compile with warnings$ g++ -Wall -Wextra [source.cpp] -o [output]
Compile with optimization$ g++ -O2 [source.cpp] -o [output]
Debug build$ g++ -g [source.cpp] -o [output]
Compile with C++ standard$ g++ -std=c++17 [source.cpp] -o [output]
SYNOPSIS
g++ [options] files...
DESCRIPTION
g++ is the GNU C++ compiler, part of the GNU Compiler Collection. It compiles C++ source code to executables or object files, supporting modern C++ standards.The compiler handles preprocessing, compilation, assembly, and linking. It provides extensive optimization options and warning controls for quality code production.g++ is the standard C++ compiler on Linux systems, supporting the full range of C++ language features.
PARAMETERS
FILES
Source files to compile.-o FILE
Output filename.-c
Compile only, no linking.-Wall
Enable common warnings.-Wextra
Enable additional warnings beyond -Wall.-g
Generate debug info.-O LEVEL
Optimization level (0-3, s, fast).-std=STANDARD
C++ standard (c++11, c++14, c++17, c++20, c++23).-I PATH
Include path.-L PATH
Library path.-l LIBRARY
Link library.--help
Display help information.
CAVEATS
Large codebases compile slowly. Template errors can be cryptic. Different standards have different feature sets.
HISTORY
g++ is part of GCC (GNU Compiler Collection), originally written by Richard Stallman. It evolved from the original GNU C Compiler to support multiple languages including C++.
