How to Compile and Install Software from Source in Linux


Linux distributions have extensive repositories most of them are free and open source letting you compile your own. But sometimes you will have to compile from source when you come across a confusing application or a new program version.

And here is a guide on how to compile and install software from source in Linux.

Step 1 – Install the required tools

Firstly, you need to install other packages such as curl and gettext

Run:

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

Output:

Install-Compile-Sofware-Source-Linux

Step 2 – Download the Package Source Code

Firstly, navigate to the Downloads directory:

$ cd ~/Downloads

Output:

Install-Compile-Sofware-Source-Linux

Then run the following command, we choose Git version 2.26.2:

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

Output:

Install-Compile-Sofware-Source-Linux

To extract, run the tar command:

$ tar -zxf git.tar.gz

Output:

Install-Compile-Sofware-Source-Linux

Step 3 – Compile the Source Code

Let’s navigate to the extracted folder:

$ cd git-2.26.2

Output:

Install-Compile-Sofware-Source-Linux

Then run the following command to configure:

$ ./configure

Output:

Install-Compile-Sofware-Source-Linux

Step 4 – Build the Software

Run the following command:

$ make

Output:

Install-Compile-Sofware-Source-Linux

The compilation will take some time, please wait.

Finally, install the Git software package:

$ sudo make install

Output:

Install-Compile-Sofware-Source-Linux

Check the version:

$ git --version

Output:

Install-Compile-Sofware-Source-Linux

Conclusion

Above is a tutorial on how to compile and install software from a source in Linux.

Thank you for reading.

Print Friendly, PDF & Email