LinuxCommandLibrary

g++

GNU C++ compiler

TLDR

Compile C++ file

$ g++ [source.cpp] -o [output]
copy
Compile with warnings
$ g++ -Wall -Wextra [source.cpp] -o [output]
copy
Compile with optimization
$ g++ -O2 [source.cpp] -o [output]
copy
Debug build
$ g++ -g [source.cpp] -o [output]
copy
Compile with C++ standard
$ g++ -std=c++17 [source.cpp] -o [output]
copy

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 all warnings.
-g
Generate debug info.
-O LEVEL
Optimization level (0-3, s, fast).
-std STANDARD
C++ standard (c++11, c++14, c++17, c++20).
-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++.

SEE ALSO

gcc(1), clang++(1), make(1)

> TERMINAL_GEAR

Curated for the Linux community

nuphy Air75 V2 Portable 75% Mechanical Keyboard,Wireless Keyboard

nuphy Air75 V2 Portable 75% Mechanical Keyboard,Wireless Keyboard

$129.95
BOSGAME Mini PC N95, Intel 12th Mini Computers| 16GB DDR4 RAM| 512GB M.2 2280 SSD| 4K 60HZ Triple Displays by Dual HDMI+Type-C, 6W TDP Quiet Mini PC, WIFI5, BT 5.0 Office

BOSGAME Mini PC N95, Intel 12th Mini Computers| 16GB DDR4 RAM| 512GB M.2 2280 SSD| 4K 60HZ Triple Displays by Dual HDMI+Type-C, 6W TDP Quiet Mini PC, WIFI5, BT 5.0 Office

$239.99
GMKtec Gaming PC, K11 AMD Ryzen 9 8945HS, 32GB DDR5 RAM 1TB Mini PC Desktop Computer, Oculink, Dual NIC 2.5GbE LAN, HDMI/DisplayPort/USB4*2

GMKtec Gaming PC, K11 AMD Ryzen 9 8945HS, 32GB DDR5 RAM 1TB Mini PC Desktop Computer, Oculink, Dual NIC 2.5GbE LAN, HDMI/DisplayPort/USB4*2

$739.99
Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community

GMKtec Gaming PC, K11 AMD Ryzen 9 8945HS, 32GB DDR5 RAM 1TB Mini PC Desktop Computer, Oculink, Dual NIC 2.5GbE LAN, HDMI/DisplayPort/USB4*2

GMKtec Gaming PC, K11 AMD Ryzen 9 8945HS, 32GB DDR5 RAM 1TB Mini PC Desktop Computer, Oculink, Dual NIC 2.5GbE LAN, HDMI/DisplayPort/USB4*2

$739.99
nuphy Air75 V2 Portable 75% Mechanical Keyboard,Wireless Keyboard

nuphy Air75 V2 Portable 75% Mechanical Keyboard,Wireless Keyboard

$129.95
BOSGAME Mini PC N95, Intel 12th Mini Computers| 16GB DDR4 RAM| 512GB M.2 2280 SSD| 4K 60HZ Triple Displays by Dual HDMI+Type-C, 6W TDP Quiet Mini PC, WIFI5, BT 5.0 Office

BOSGAME Mini PC N95, Intel 12th Mini Computers| 16GB DDR4 RAM| 512GB M.2 2280 SSD| 4K 60HZ Triple Displays by Dual HDMI+Type-C, 6W TDP Quiet Mini PC, WIFI5, BT 5.0 Office

$239.99