The hardest part of compiling software on Linux is locating its dependencies and installing them. Ubuntu has apt commands that automatically detect, locate and install dependencies, doing the hard work for you.
We recently covered the basics of compiling software from source on Ubuntu, so check out our original article if you’re just getting started.
Auto-apt watches and waits when you run the ./configure command through it. When ./configure tries to access a file that doesn’t exist, auto-apt puts the ./configure process on hold, installs the appropriate package and lets the ./configure process continue.
First, install auto-apt with the following command:
sudo apt-get install auto-apt
Once it’s installed, run the following command to download the file lists it auto-apt requires. This process will take a few minutes.
sudo auto-apt update
After the first command is done, run the following commands to update its databases. These commands will also take a few minutes.
sudo auto-apt updatedb && sudo auto-apt update-local
After your’e done building auto-apt’s databases, you can start the ./configure process with the following command:
sudo auto-apt run ./configure
If you see an error message that says a specific file is missing, you may not know the package you have to install to get the file. Apt-file lets you find the packages that contain a specific file with a single command.
First, you’ll have to install apt-file itself:
sudo apt-get install apt-file
After it’s installed, run the following command to download the file lists from your configured apt repositories. These are large lists, so downloading them will take a few minutes.
sudo apt-file update
Run the following command, replacing “example.pc” with a file name, and the command will tell you exactly which package you need to install:
apt-file search file example.pc
Install the package with the standard apt-get install command:
sudo apt-get install package
You can also perform a file search from the Ubuntu Package Search website. Use the “Search the contents of packages” section on the page to search a specific file.
It’ll give you the same results as apt-file, and you won’t have to download any file lists.
We covered apt-get build-dep in our initial post. If an earlier version of the program you’re trying to install is already in Ubuntu’s package repositories, Ubuntu already knows the dependencies it requires.
Type the following command, replacing “package” with the name of the packge, and apt-get will install the required dependencies:
sudo apt-get build-dep package
Apt-get prompts you to install all the required dependencies.
If a newer version of the program requires different dependencies, you may have to install some additional dependencies manually.
All these commands use apt-get, so you can also them on Debian, Linux Mint and any other Linux distribution that uses apt-get and .deb packages.
Chris Hoffman is a technology writer and all-around computer geek. He's as at home using the Linux terminal as he is digging into the Windows registry. Connect with him on Google+.
- Published 02/22/12