Solve “file’s missing” error while compiling packages from source in Ubuntu and its clones

How often have we faced issues while trying to compile a package from source. Lots of time is spent googling to find out the solution blindly. Many times we revert to different versions just to solve the compilation issue rather than work on the actual task which we want to do.

Now there is a solution to these issues at least for ubuntu clones. This is a simple and intuitive way to check the missing files which belongs to a certain package and then go ahead and install them so that we can continue to work on our task.

apt-file is the tool which helps us to solve these kinds of issue.

If you are using ubuntu distro or any of it clones like mint or ubuntu mate you can simply install it by using the apt command as we normally install packages.

The demo machine is actually running ubuntu mate which is based on ubuntu 16.04 LTS.

First of all let us update the local repos:

kasi@kasi-desktop:~$ sudo apt-get update
Let us do a quick search using apt command to check whether the package is available for us to go ahead and install:

kasi@kasi-desktop:~$ apt-cache search apt-file
apt-file – search for files within Debian packages (command-line interface)
cabal-debian – Create a debianization for a cabal package

As you can see the package is available for us to install. So let us go ahead and install the package apt-file:

kasi@kasi-desktop:~$ sudo apt-get install apt-file
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following NEW packages will be installed:
apt-file
0 upgraded, 1 newly installed, 0 to remove and 199 not upgraded.
Need to get 0 B/21.6 kB of archives.
After this operation, 92.2 kB of additional disk space will be used.
Selecting previously unselected package apt-file.
(Reading database … 372978 files and directories currently installed.)
Preparing to unpack …/apt-file_2.5.5ubuntu1_all.deb …
Unpacking apt-file (2.5.5ubuntu1) …
Processing triggers for man-db (2.7.5-1) …
Setting up apt-file (2.5.5ubuntu1) …
The system-wide cache is empty. You may want to run ‘apt-file update’
as root to update the cache. You can also run ‘apt-file update’ as
normal user to use a cache in the user’s home directory.

The package has been installed and before proceeding we need to update the cache which the package looks into when we query it. Just run apt-file update command which will update the system wide cache. Pls note that it make sometime to update the cache as it depends upon your network speed.

kasi@kasi-desktop:~$ apt-file update
apt-file is now using the user’s cache directory.
If you want to switch back to the system-wide cache directory,
run ‘apt-file purge’
Downloading complete file http://in.archive.ubuntu.com/ubuntu/dists/xenial/Contents-amd64.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 31.7M 100 31.7M 0 0 405k 0 0:01:20 0:01:20 –:–:– 452k
Downloading complete file http://in.archive.ubuntu.com/ubuntu/dists/xenial-updates/Contents-amd64.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 5451k 100 5451k 0 0 376k 0 0:00:14 0:00:14 –:–:– 313k
Downloading Index http://in.archive.ubuntu.com/ubuntu/dists/xenial/Contents-amd64.diff/Index:
No Index available.
Downloading complete file http://in.archive.ubuntu.com/ubuntu/dists/xenial/Contents-amd64.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 –:–:– –:–:– –:–:– 0
File is up-to-date.
Downloading Index http://in.archive.ubuntu.com/ubuntu/dists/xenial-updates/Contents-amd64.diff/Index:
No Index available.
Downloading complete file http://in.archive.ubuntu.com/ubuntu/dists/xenial-updates/Contents-amd64.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 –:–:– –:–:– –:–:– 0
File is up-to-date.
Downloading Index http://in.archive.ubuntu.com/ubuntu/dists/xenial/Contents-amd64.diff/Index:
No Index available.
Downloading complete file http://in.archive.ubuntu.com/ubuntu/dists/xenial/Contents-amd64.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 –:–:– –:–:– –:–:– 0
File is up-to-date.
Downloading Index http://in.archive.ubuntu.com/ubuntu/dists/xenial-updates/Contents-amd64.diff/Index:
No Index available.
Downloading complete file http://in.archive.ubuntu.com/ubuntu/dists/xenial-updates/Contents-amd64.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 –:–:– –:–:– –:–:– 0
File is up-to-date.
Downloading complete file http://in.archive.ubuntu.com/ubuntu/dists/xenial-backports/Contents-amd64.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1702 100 1702 0 0 5269 0 –:–:– –:–:– –:–:– 5285
Downloading complete file http://security.ubuntu.com/ubuntu/dists/xenial-security/Contents-amd64.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2619k 100 2619k 0 0 420k 0 0:00:06 0:00:06 –:–:– 464k
Downloading Index http://security.ubuntu.com/ubuntu/dists/xenial-security/Contents-amd64.diff/Index:
No Index available.
Downloading complete file http://security.ubuntu.com/ubuntu/dists/xenial-security/Contents-amd64.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 –:–:– –:–:– –:–:– 0
File is up-to-date.
Downloading Index http://security.ubuntu.com/ubuntu/dists/xenial-security/Contents-amd64.diff/Index:
No Index available.
Downloading complete file http://security.ubuntu.com/ubuntu/dists/xenial-security/Contents-amd64.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 –:–:– –:–:– –:–:– 0
File is up-to-date.
Downloading complete file https://apt.dockerproject.org/repo/dists/ubuntu-xenial/Contents-amd64.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 –:–:– –:–:– –:–:– 0
curl: (22) The requested URL returned error: 403 Forbidden
Download of https://apt.dockerproject.org/repo/dists/ubuntu-xenial/Contents-amd64.gz failed
Command exited with code 22
Ignoring source without Contents File:
http://dl.google.com/linux/chrome/deb/dists/stable/Contents-amd64.gz
kasi@kasi-desktop:~$

The above command has updated its local cache which is used for searching the missing files. Let us test it by trying to compile a package from source. Below is the error which i got while trying to compile a package (hostap) from source:

fatal error: netlink/genl/genl.h: No such file or directory

Since we have apt-file installed let us use it to try to solve the above issue.

kasi@kasi-desktop:~$ apt-file search netlink/genl/genl.h
libnl-3-dev: /usr/include/libnl3/netlink/genl/genl.h
kasi@kasi-desktop:~$

apt-file clearly shows to that the missing file is part of the libnl-3-dev package. The issue can be resolved by just installing the missing package. If multiple references to the same file exists (example ssl.h ) then apt-file reports all the packages which provides the queried file. This is really cool as we wont be wasting time to resolve these dependency issues.

There are lot of configuration options available for apt-file which i leave to you to explore.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s