One of the hardest adjustments for users moving from Windows to Linux is the idea that not all of the programs you want to install are ready for you. Unlike Windows users who (in most cases) receive the software as an EXE or ZIP installer, Linux users often have to compile their own software packages.
If you want to learn how to compile software packages on Linux, there are a few steps to follow. You will need to download the source, run the configure command, install any required dependency packages, and then run the make command to start compiling your package. Here’s how to do it on a Linux-based operating system.
Download source files
Before you start building your new software packages, you need the source code. It could be a package that you developed yourself, in which case you should already have access to the source code.
However, it is more likely that you are trying to compile a Linux software package from another developer. Popular code sharing sites like Github allow you to view and download the source code of packages, which you can then compile. You can use GIT, a popular version control system, to download the source files to your computer.
You can also directly download the source code from open source projects like VLC. They are usually in a compressed file format such as TAR.GZ, which can be extracted from a terminal using the tar command. For example, running the command tar -xzvf source.tar.gz will extract an archive file named source.tar.gz.
Once the source code is available and unpacked on your Linux PC, you can move on to the next preparation step before you start compiling your package.
– /
Install Build-Essential on Linux
The tools and software contained in the build-essential package are essential for any type of software compiled on Linux operating systems, regardless of the programming language of your source code.
As a required package, build packages (or packages with similar names) should be available in the software repository of your Linux distribution. The Arch Linux-based equivalent of build-essential is called base-devel, which includes many of the same tools.
The installation instructions for build-essential will also differ depending on your Linux distribution. For example, on Ubuntu and Debian based operating systems, you can install build-essential by opening a terminal window and typing sudo apt install build-essential.
Installing build-essential will also install its dependencies, such as the g ++ package. Once this process is complete, you can move on to customizing your Linux source package before compiling it.
Run config command
The source code for core packages usually contains a configuration script. Running this script will check your Linux distribution for the necessary packages that your source code needs to compile correctly.
To run the configuration script, enter the location of the extracted source code using the cd command. From there, type ./configure into a terminal and press Enter to launch it.
If the configuration script finds a missing package, it will tell you what to do at the end of the script. For example, before compiling the VLC media player, the configuration script shown above found that the Lua programming language was not installed.
In some cases, you can still compile and customize software packages even if the customization script finds a missing package or feature. The VLC configure script (shown above) provides a solution for the missing Lua programming language packages by suggesting that you run it again with the –disable-lua flag to bypass it.
You will need to install any missing packages found by the config script, or use any suggested disable flags to work around these errors before you can proceed.
If the configuration script completed without errors (or without errors), a customized makefile for your package will be generated. This creates instructions for compiling your package, allowing you to proceed to the final stage of compiling your software.
Install missing dependency packages
The configure script helps you identify any packages that your Linux distribution needs to properly compile and install a new software package.
They can be clearly identified by your customization script error message or during the execution of that script. If the error message does not clear up, scroll back in your terminal history to try to identify the missing package.
Once you know which package is missing, use the package installer for your Linux distribution to install it. For example, on Ubuntu and Debian based operating systems, running sudo apt install package-name will install the package.
Installing any missing dependencies is the last step you need to complete before you can start compiling and installing a new software package. Once this process is complete, compilation can begin.
How to Compile on Linux
The build-essential package contains make, an automatic tool used to start compiling source code into software that you can run on your PC. It uses a makefile configured and generated by the previous configure command, which contains the specific instructions needed to compile your package.
To start compiling the source code, open a terminal and use the cd command to enter the correct folder. When ready, enter make to start compiling the package.
It will take a little time, depending on the package size and available system resources. If there are no errors after compiling the software package, you can install it.
To do this, enter sudo make install in a terminal. The package will be installed on your Linux computer, and you can open and use it like any other software.
Install new software on Linux
Knowing how to compile software packages on Linux can help you install lesser known software. Major operating systems like Ubuntu and Devian have large software repositories available to users, so if you don’t want to compile your software, try finding and installing new software using the package manager.
If you’re migrating from Windows, you can also install Windows software on Linux to continue using your favorite Windows-only apps.
–