LOGO

Compile & Install TAR.GZ & TAR.BZ2 Files in Ubuntu Linux

December 29, 2010
Compile & Install TAR.GZ & TAR.BZ2 Files in Ubuntu Linux

Software Installation in Linux: A Detailed Guide

The process of installing software in Linux can, at times, present a greater degree of complexity when contrasted with Windows. This is particularly true if the desired software isn't readily available as a pre-built package or within established repositories.

Typically, such instances necessitate compiling and installing directly from archive files, commonly in .TAR.GZ or .TAR.BZ2 formats.

Navigating the Compilation Process

While initially daunting, this process becomes manageable with a systematic approach. A common scenario involves encountering an archive that requires installation.

The following methodology outlines a procedure to create a package from the archive, facilitate installation, and ensure a clean removal process through your system’s package manager.

Step-by-Step Installation Method

Preparation is key. Ensure you have access to a command line interface and are ready to execute the necessary commands.

This method will allow you to install software from source and manage it effectively using your distribution’s package management tools.

  • First, extract the archive using a command like tar -xzvf filename.tar.gz or tar -xjvf filename.tar.bz2.
  • Navigate into the extracted directory.
  • Typically, you'll find instructions in a file named INSTALL or README. Follow these instructions carefully.
  • Often, the installation process involves running commands like ./configure, make, and sudo make install.

By adhering to these steps, you can successfully install software from source in Linux and maintain a streamlined management experience.

This approach provides a structured way to handle software installations, offering both control and convenience.

Compressed Software Archives: Understanding Tarballs

A file ending in .TAR.GZ or .TAR.BZ2 represents a tarball – a compressed archive containing the source code for a software application. Successfully installing software from these files necessitates compiling, processing, and linking the code so that your Ubuntu system can run the program.

The tarball format achieved standardization in 1988, with a subsequent revision in 2001, and remains a prevalent method for software distribution across both Linux and Windows operating systems.

Initially, tarballs were conceived to streamline data backups to tape drives, a practice less common today.

Working with Tarballs: A Beginner's Guide

For those unfamiliar with the Linux command line, the necessary commands are generally uncomplicated and logically structured.

Don't be intimidated; the process is designed to be accessible.

These archives provide a fundamental method for software distribution and installation within the Linux ecosystem.

  • Key Takeaway: Tarballs contain source code, requiring compilation for execution.
  • Historical Context: The format originated for tape backups but now serves broader distribution purposes.
  • Accessibility: Command-line operations for handling tarballs are relatively straightforward.

Understanding the nature of tarballs is crucial for anyone venturing beyond pre-packaged software installations on Linux systems.

System Preparation

To begin, the installation of two packages is required: build-essential, which facilitates package creation from source code, and checkinstall, enabling straightforward removal via your package manager. This process is efficiently executed through the console. Simply launch Terminal (located in Applications, then Accessories, and finally Terminal) and enter the following command:

sudo apt-get install build-essential checkinstall

Allow sufficient time for the download and installation of these components. Following this, consider installing version control software for future upgrades, although this step can be deferred. These three packages are recommended:

sudo apt-get install subversion git-core mercurial

A designated directory is needed for building packages. While placement is flexible, write access is essential. Ubuntu’s official documentation suggests using:

/usr/local/src

Therefore, we will adopt this convention:

sudo chown $USER /usr/local/src

Subsequently, ensure write permissions are granted:

sudo chmod u+rwx /usr/local/src

The apt-file utility will also be installed to assist in resolving any dependency problems encountered during the process:

sudo apt-get install apt-file

compile-install-tar-gz-tar-bz2-files-ubuntu-linux-2.jpg

A prompt may appear requesting an update to apt-file; if not, execute the following command and allow it to complete:

sudo apt-file update

Upon completion, your system will be fully prepared for handling any tarball installations, and this update will not be necessary in the future.

Extract and Prepare Software Archives

Assuming a .TAR.GZ file has been downloaded, the initial step involves relocating it to a designated build directory, such as

/usr/local/src

. This can be accomplished using a standard file browser, after which a new Terminal window should be opened.

compile-install-tar-gz-tar-bz2-files-ubuntu-linux-3.jpg

Navigate to the build directory by executing the following command:

cd /usr/local/src

Subsequently, extract the archive. For .TAR.GZ archives, use:

tar -xzvf <filename>.tar.gz

Alternatively, for .TAR.BZ2 archives, employ:

tar -xjvf <filename>.tar.bz2

compile-install-tar-gz-tar-bz2-files-ubuntu-linux-4.jpg

A successful extraction will be indicated by a comprehensive list of extracted files, as illustrated in the image above. Do not close the Terminal at this stage, as further steps are required.

It is strongly recommended to navigate to the newly created folder—using your preferred file browser—and examine any available README or INSTALL files. These files often contain crucial instructions for software installation, potentially differing from the standard procedure outlined here. Consulting these resources can prevent significant difficulties.

The INSTALL or README files may also detail available installation options. These files, typically plain text, can be opened with Gedit or any text editor.

General Installation Procedure

Generally, the following commands will initiate the software installation process using the default settings.

Change to the directory created by the extracted archive, which usually shares the archive’s filename, using the cd command:

cd /usr/local/src/<extracted folder>

compile-install-tar-gz-tar-bz2-files-ubuntu-linux-5.jpg

Replace <extracted folder> with the actual name of the extracted directory. Then, configure the source files by typing:

./configure

Important: If the software lacks a configure file, consider proceeding directly to the Build & Install section, but first, review the INSTALL or README documentation.

Should an error message concerning autoconf appear, install it using:

sudo apt-get install autoconf

Then, rerun

./configure

.

compile-install-tar-gz-tar-bz2-files-ubuntu-linux-6.jpg

This command checks for the necessary installed packages. The previously installed apt-file utility can assist in identifying missing dependencies.

If an error arises—such as

configure: error: Library requirements ... not met

—examine the error message for the missing file and use apt-file to locate the corresponding package:

apt-file search <filename>.<extension>

This will reveal the package containing the required file, allowing you to install it with:

sudo apt-get install <package>

This situation doesn't always occur, but it's a valuable troubleshooting step when dependencies are missing.

Once you’ve addressed any dependency issues, execute the

./configure

command again.

compile-install-tar-gz-tar-bz2-files-ubuntu-linux-7.jpg

A successful configuration process will display

config.status: creating Makefile

- indicating that you are nearing completion. Many users encounter difficulties before reaching this point, but you have progressed successfully.

Compilation and Installation

Within the same Terminal window, execute the following command:

make

Allow the process to run its course. The duration will vary depending on the size of the installation.

compile-install-tar-gz-tar-bz2-files-ubuntu-linux-8.jpg

Following compilation, the program can be installed using this command:

sudo checkinstall

Proceed through the prompts displayed on the screen. Provide a descriptive summary for the software, then press Enter at the subsequent screen.

compile-install-tar-gz-tar-bz2-files-ubuntu-linux-9.jpg

A successful installation will be indicated by the message Installation Successful. Congratulations on completing the process.

compile-install-tar-gz-tar-bz2-files-ubuntu-linux-10.jpg

The installed software will typically reside in

/usr/local/bin

From this directory, the program can be executed without encountering issues.

compile-install-tar-gz-tar-bz2-files-ubuntu-linux-11.jpg

Were you able to follow all the steps? Is it not simpler to utilize pre-built packages or obtain the software from official repositories? Perhaps you discovered the process to be straightforward. Share your thoughts in the comments below.

#ubuntu#linux#tar gz#tar bz2#compile#install