This tutorial intends to teach you to Install the build-essential package on Ubuntu 22.04. If you plan to build a program from the source, you need to have the essential tools for it. build-essential package provides a set of essential packages and tools required to build or compile software from its source code. The packages include libc, gcc, g++, make, dpkg-dev, etc. You can easily install them in one single package.
Now follow the steps below to install this package and see an example of building a package from the source.
Steps To Install build-essential on Ubuntu 22.04
To complete this guide, you must have access to your server as a non-root user with sudo privileges. For this purpose, you can check this guide on Initial Server Setup with Ubuntu 22.04.
Step 1 – Run Ubuntu System Update
The first step is that your local packages have been up to date. To do this, you can run the system update with the following command:
# sudo apt update
# sudo apt upgrade -y
Step 2 – How To Install build-essential in Ubuntu?
The build-essential package is available in the Ubuntu 22 default repository. You can easily install it on your server by using the following command:
sudo apt install build-essential -y
Setting up build-essential (12.9ubuntu3) ...
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for libc-bin (2.35-0ubuntu3.1) ...
Scanning linux images...
Running kernel seems to be up-to-date.
Step 3 – How To Compile and Build an App from Source?
At this point, we want to show you the process of compiling and building an app from the source. When your installation of build-essential on your Ubuntu 22 is completed, follow the steps below to see how to build an app from the source.
Install Dependencies to build an app from the source
When installing a package from source code, you’ll need to manage the installation of the package dependencies. To do this, you can run the command below:
sudoo apt install dh-autoreconf libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev -y
Now follow the steps below to build your app on Ubuntu:
- First, you need to download the source code of your desired app.
- Then, extract your downloaded file to a directory.
- Next, switch to your app directory.
- Inside your app directory, you need to run the ./configure script to check your system for any necessary dependencies and generate a Makefile:
- Then, you need to compile your program by using the make command:
- When your make process is completed, you can easily install your app by using the command below on Ubuntu 22:
Why is better to build an app from source code instead of downloading it as a package?
Maybe your package manager depends on your OS doesn’t have the available package. So it is recommended to build your package from the source in the latest version. Also, you can control your package by yourself.
At this point, you have learned to Install the build-essential package on Ubuntu 22.04, install the dependencies for building a package, and compile and build a program for the source.
Hope you enjoy it. You may be interested in these articles too: