TASIOMIND.DEV — OPERATIONAL▸▸▸FULL STACK DEVELOPER @ GWQ SERVICEPLUS AG▸▸▸FOUNDER — K8SGPT.AI▸▸▸OPEN SOURCE: ACTIVE▸▸▸DISTRIBUTED SYSTEMS / KUBERNETES / AI▸▸▸RUST + GO + PYTHON▸▸▸FIELD TESTED / STATUS — NOMINAL▸▸▸LOCATION: EUROPE/BERLIN▸▸▸TASIOMIND.DEV — OPERATIONAL▸▸▸FULL STACK DEVELOPER @ GWQ SERVICEPLUS AG▸▸▸FOUNDER — K8SGPT.AI▸▸▸OPEN SOURCE: ACTIVE▸▸▸DISTRIBUTED SYSTEMS / KUBERNETES / AI▸▸▸RUST + GO + PYTHON▸▸▸FIELD TESTED / STATUS — NOMINAL▸▸▸LOCATION: EUROPE/BERLIN▸▸▸

Running and Compiling C/C++ code on Linux

November 17, 2019

C/C++ support is usually already there on Ubuntu

code
g++ --version
gcc --version
  • If not, install build-essential
  • build-essential includes gcc, g++ and make as well as libc-dev
code
sudo apt install build-essential manpages-dev

The file extension is .cpp on Linux or .C

Sample program

code
hello.cpp
code
#include <stdio.h>

int main() {
  printf("bonjour le monde!");
  return 0;
}

Compile code

code
g++ hello.cpp

By default it'll generate a file called a.out

code
g++ hello.cpp -o output

output will be the generated binary file

Run code

code
./output