You need to install following packages on Debian and Ubuntu Linux:
build-essential package Installs the following collection to compile c/c++ program on a Ubuntu Linux including:
- libc6-dev C standard library.
- gcc C compiler.
- g++ C++ compiler.
- make GNU make utility to maintain groups of programs.
- dpkg-dev Debian package development tools.
Basically, build-essential package contains an informational list of packages which are considered essential for building Ubuntu packages including gcc compiler, make and other required tools. This package also depends on the packages on that list, to make it easy to have the build-essential packages installed. In this tutorial, you will learn about installing the GNU C compiler and GNU C++ compiler on a Ubuntu Linux.
Installing compilers using apt command
Open the terminal app and type the following apt command/apt-get command:
$ sudo apt update
$ sudo apt upgrade
$ sudo apt install build-essential
OR
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install build-essential
Sample outputs:
Fig.01: How do I install development tools for Ubuntu Linux?
Verify installation
Type the following commands:
$ whereis gcc make
$ gcc --version
$ make -v
Fig.02: Finding out installed make and gcc version
Installing the dev man pages on a Ubuntu Linux
Type the following command:
$ sudo apt-get install manpages-dev man-db manpages-posix-dev
To view library calls (functions within program libraries), enter:
$ man 3 scanf
$ man 2 execve
$ man 2 fork
You can write a small program to test GNU c/c++ compiler:
$ vi test.cpp
Append the following code:
#include <iostream> // My first program using namespace std; int main(){ cout << "Hello, World!\n"; return 0; }
Save and close the program. You can compile it as follows:
$ make test
OR
$ g++ test.cpp -o test
You should get an executable named test in the current directory:
$ ls -l test
Sample outputs:
-rwxr-xr-x 1 vivek vivek 8768 Dec 11 14:49 test
Just run it:
$ ./test
Installing the X11 development compilers
Type the following command:
$ sudo apt install libx11-dev
ð§ 0 comments... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |