Find out how to Compile and Set up Software program From Supply in Linux

Would you like to fix a bug in a software package or simply adapt a package to your needs? Linux has you covered.

Most Linux packages are free and open source, so you can customize or change any software to your liking. In addition, you can also look at the source code of Linux packages to learn good architectural practices and coding patterns from other software projects.

Let's see how to compile and install a package from source on Linux.

Linux gives you all the tools you need to compile, build, and install software from source.

Most Linux software is written in the C or C ++ programming languages, so you will need a C or C ++ compiler. For example the GNU Compiler Collection (GCC) and CMake for building your package.

You will also need other packages like curl and gettext. Depending on your Linux distribution, you can install the necessary tools in a single command as follows.

On Debian-based distributions like Ubuntu:

sudo apt install libz-dev libssl-dev libcurl4-gnutls-dev libexpat1-dev gettext cmake gcc curl

On Arch Linux and its derivatives:

MAKEUSEOF VIDEO OF THE DAY
sudo pacman -S base-devel

On RPM based distributions like Fedora, RHEL etc .:

sudo dnf install dh-autoreconf curl-devel expat-devel gettext-devel openssl-devel perl-devel zlib-devel gcc curl cmake

Learn more: How to manage software packages with DNF

Step 2: Download the package source code

For this tutorial, we'll install the Git package from source. We chose Git because it is widely used among software engineers and developers.

Most of the packages that you can put together can be found on the official website of each package. You can download the source code files using the curl command line tool. Alternatively, you can wget or the GUI.

Download the source code to the Downloads folder on your PC, then use the cd command to switch to the Downloads directory.

cd ~ / Downloads

Once you are in the Downloads folder, you can curl to download the Git source code as follows. In this guide, we're going to download Git version 2.26.2, but you can choose whichever version you want.

curl –output git.tar.gz https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.26.2.tar.gz

The curl command indicates that the source code is in a zipped file called. should be filed git.tar.gz.

Download: Git source code for Linux

In most cases, the source code is packed into a compressed folder for easier downloading and for better organization of the source code files.

To extract the contents of the zipped file, you can use the tar Command.

tar -zxf git.tar.gz

Step 3: Compiling the Source Code

Next, go to the newly extracted folder. In this case the name is "git-2.26.2", the folder name will of course be different if you downloaded a different version of Git.

cd git-2.26.2

It's always a good idea to take a look at that README.md or TO INSTALL Files as they contain valuable information about compiling and installing the package. These files are usually located in the root folder of the source code.

Another important file is the configure Script. It will check for software dependencies for the package you are trying to compile and you will receive an error message if the script finds any missing dependencies.

Configure and prepare your source code by running the script. The command creates do Files and configurations for the software that you want to compile and install.

./configure

Step 4: Creating the software package

After the source code has been configured and compiled, you can build the software as follows:

do

The make command uses the Makefile, which contains the necessary instructions to create the software package.

The compilation process will take some time, depending on the processing power of your computer and the size of the package.

Step 5: Install the software package

If you have come this far, congratulations, you have successfully compiled and built Linux software from source.

In this final step, you will install the Git software package that you just built from source code. This command installs the newly compiled package by copying the build files to the correct locations on your PC.

make sudo install

Check the version of Git you just installed with the command:

git –version

The output should be similar to the following. The version number may vary depending on the package downloaded.

Alternative methods of installing software on Linux

This guide examined how to compile and build software from source on Linux using Git as a case study. Installing software from source gives you so much freedom to customize the software the way you want, which is an amazing thing.

Most Linux distributions give you many options when it comes to installing software. For example, on Arch Linux you can use the Pacman and Yay package managers.

How to install and remove packages in Arch Linux

Using Arch Linux? Installing and removing packages is different from Ubuntu and Mint. Here's what you need to know.

Continue reading

About the author

Mwiza Kumwenda
(42 published articles)

Mwiza is a professional developer of software and writes extensively on Linux and front-end programming. Some of his interests include history, economics, politics, and enterprise architecture.

More
By Mwiza Kumwenda

Subscribe to our newsletter

Subscribe to our newsletter for tech tips, reviews, free e-books, and exclusive offers!

Click here to subscribe

Leave a Reply

Your email address will not be published. Required fields are marked *