Ny automatic tool for installing required libraries to compile a program from source

compilinglibrariespackage-managementsource

I want to know if there is any tool that, given the output of configure, cmake, autoconf or whatever library/dependencies matcher you have; installs the required packages/sources for you from your distro repo.

In other words, some tool that resolves library dependencies for you, installing needed packages depending on your repo, when you want to build a program from source which you don't know which libraries are required.

I give you a random example:
Some time ago I wanted to use Oprofile. It isn't packaged for Ubuntu 14.04 so I had to build for myself.
In the README file it says I have to do ./configure first.
I did ./configure once, it threw out an error saying "popt" library wasn't found. I looked up on Internet, I discovered which deb package I had to install for that library, I installed it and I did ./configure again.
Second time, it again threw an error saying liberty library wasn't found. Again, I looked up what library I needed, I found that for Ubuntu it was binutils-dev. But when I tried to install it, It didn't work. Funny enough, that library was in binutils-dev package for ubuntu 12.04, but libiberty-dev for ubuntu 14.04.
For the third time, I finally was able to compile it and run the program

Best Answer

No, it can't fully automatically infer dependencies.

If it had been packaged, apt-get build-dep oprofile would have helped. If you can find a package elsewhere, you can look up the dependencies there. For example, if the package exists in the next release of your distribution. e.g. here:

http://archive.ubuntu.com/ubuntu/pool/universe/o/oprofile/oprofile_1.0.0-0ubuntu9.dsc

(and if you plan on compiling things yourself, always consider upgrading to the latest version first!)

Other than that it requires a little bit of experience to figure out. configure scripts unfortunately won't tell you the package names, but usually it's quite easy to find. Also use the search functions on the distribution web pages - they can tell you which packages contain a certain file name.

Instead of iterating through configure attempts, it may be more convenient to look at the configure.ac file, from which the script was generated (and which usually is much shorter). You may be able to discover some optional functionality only offered if certain libraries are installed and some flag is given.

LIBERTY_LIBS="-liberty $DL_LIB $INTL_LIB"
BFD_LIBS="-lbfd -liberty $DL_LIB $INTL_LIB $Z_LIB"
POPT_LIBS="-lpopt"

are typical library dependencies.

AC_ARG_ENABLE(gui,[  --enable-gui  compile with gui component (qt3|qt4|yes|no),
         if not given or set to yes, gui defaults to qt3],, enable_gui=qt3)

indicates that you may also want to consider QT dependencies if you want a GUI.

Related Question