Finding the package that contains a particular file in Ubuntu

It often happens that a file is missing during compilation and you get this kind of error:

In file included from media/audio/linux/audio_manager_linux.cc:15:0:
./media/audio/linux/alsa_input.h:8:28: fatal error: alsa/asoundlib.h: No such file or directory
compilation terminated.
In file included from media/audio/linux/alsa_input.cc:5:0:
./media/audio/linux/alsa_input.h:8:28: fatal error: alsa/asoundlib.h: No such file or directory
compilation terminated.

That usually means a development package is missing. Sometime you can just guess the name of the package or you can use aptitude to find the file.

There is also another (better) method in Ubuntu: apt-file utility allows you to find the package corresponding to a particular file.

First install apt-file

sudo apt-get install apt-file

Them the first time, you need to download the files with the data for your system

apt-file update

Finally, you can use apt-file to find the package. For example with alsa/asoundlib.h

apt-file search alsa/asoundlib.h
libasound2-dev: /usr/include/alsa/asoundlib.h

 

Jean-Luc started CNX Software in 2010 as a part-time endeavor, before quitting his job as a software engineering manager, and starting to write daily news, and reviews full time later in 2011.

Support CNX Software - Donate via PayPal, become a Patron on Patreon, or buy review samples
Subscribe
Notify of
guest
0 Comments
Advertisements