Installing software from source code

The following section contains guidelines and best practices for installing software from source code on Fedora. The instructions below are not prescriptive, but following them minimizes the risk of errors occurring during installation.

Package management in Fedora

Like most modern Linux distributions, Fedora uses a package management system. Package management tools automate installation, upgrading, and removing of software applications and components.

Each application or component is defined as a package. When the package is installed, all code, configuration, and other files are deployed on the system.

A single package is not necessarily the same as an application. Some applications can be shipped as several packages. Moreover, shared code (libraries) in Linux is normally shipped as separate packages, while in other systems applications often ship their own versions of required libraries and install them if necessary.

File placement

The package management tools track which files on your Fedora installation belong to each package; normally, every file that is installed in the /usr tree as well as most configuration files under /etc are installed by one of the packages. When installing a package, the package management system verifies its integrity; if any files are missing or corrupted, the package is not installed.

Resolving dependencies

The package management system also tracks all dependencies between the packages. For example, if an application requires some libraries, the package for this application lists the libraries as dependencies. When you install the application package, the package management tools automatically install the library packages. If a dependency is not available, the tools do not install the package, so you can avoid a sudden malfunction.

When you want to remove a package, package management tools cleanly delete all code files for this package without affecting other packages. By default, configuration files are not removed, so you can install the package again and keep the configuration that you have set up earlier.

Updating packages

Updating any package is entirely automatic with the package management system. The system replaces all the necessary code files and preserves existing configuration.

In fact, for most Linux distributions, including Fedora, all of the system installation except the earliest part is performed by installing various packages. Security updates and upgrades to a next release are performed entirely by package management tools.

RPM

Fedora’s package management system uses the RPM package format. The application that manages packages in Fedora (since version 22) is DNF. Graphical package management is provided by the Gnome Software utility. For automatic updates, Fedora uses the PackageKit utility. Command-line and graphical tools provide the same results.

Repositories

To get packages, DNF uses repositories. A repository is an organized collection of packages. Repositories can be kept on any data media; notably, the Fedora installation image contains a repository. However, most up-to-date repositories are normally maintained online.

Each Fedora release has an official fedora repository and an updates repository (which contains critical updates since the release). In these repositories, you can find most common Linux open-source software. You can also install packages from other repositories, not maintained by the Fedora project and known as third-party repositories.

Most of the time, it is best practice to install software on your Fedora Linux system using only the Fedora package management system. In this case, packages are installed in the most reliable way and automatic updates can be provided.

Installing from source code

While many Linux applications can be built and installed from from source code, using such builds can make your system much harder to manage. For example, automatic updates to system packages (especially when updating to the next release) might impact an application that was installed from source. And, of course, no automatic security updates are available for the application.

Other installation methods

Sometimes you might need to install software using other package management systems. Notably:

  • CPAN for libraries for the Perl language

  • PyPI for libraries (and sometimes applications) for the Python language

  • Commercial repositories for games

However, installing applications using the Fedora package management systems is the preferred option.

Setting up a Development and Compiling Environment

Install packages form the C Development Tools and Libraries group:

# dnf group install @c-development

Downloading the Source Code

  1. Navigate to the directory where you want to save the source:

    cd <directory_name>
  2. Download the TAR file containing the source code you want to install from:

    wget <source_location_URL>
  3. Extract the tarball file contents to the current working directory:

    tar -xf <source_tar_filename>

Compiling Your Application

It is preferable to use DNF to using source installattion. DNF can track what packages you have installed on your system. It facilitates updates and makes it easier to completely remove your files from your system
  1. Navigate to the directory containing your source:

    cd <your_source_dir>
  2. Run the following command to compile and install your application:

    ./configure && make && make install