G++ Installation On A Debian, Ubuntu, Alpine, Arch, Kali, CentOS, Fedora And Raspbian

G++ Installation On A Debian, Ubuntu, Alpine, Arch, Kali, CentOS, Fedora And Raspbian

g++

Compiles C++ source files.
Part of GCC (GNU Compiler Collection).

Maintainer: Debian GCC Maintainers


Section: devel

Install g++

  • Debian apt-get install g++ Click to copy
  • Ubuntu apt-get install g++ Click to copy
  • Alpine OS apk add g++ Click to copy
  • Arch Linux pacman -S g++ Click to copy
  • Kali Linux apt-get install g++ Click to copy
  • CentOS yum install g++ Click to copy
  • Fedora dnf install g++ Click to copy
  • Raspbian apt-get install g++ Click to copy

Compiles C++ source files. Part of GCC (GNU Compiler Collection).

How to use g++?

Below are few example commands for g++ that you can use in the terminal.

Compile a source code file into an executable binary:
g++ source.cpp -o output_executableClick to copy
Display (almost) all errors and warnings:
g++ source.cpp -Wall -o output_executableClick to copy
Choose a language standard to compile for(C++98/C++11/C++14/C++17):
g++ source.cpp -std=language_standard -o output_executableClick to copy
Include libraries located at a different path than the source file:
g++ source.cpp -o output_executable -Iheader_path -Llibrary_path -llibrary_nameClick to copy
Install the latest version of g++ in Debian, Ubuntu, Alpine, Arch, Kali, CentOS, Fedora and Raspbian from terminal. To install the g++ just copy the above command for your OS and run into terminal. After you run the command it will grab the latest version of g++ from the respository and install it in your computer/server.