Installing from source. How to resolve dependencies without destroying the package manager
Most packages will have a <package>-dev
(for Debian based) or <package>-devel
(for Red Hat based) that will be the libraries needed to link against for building.
So, for example if the source says it requires libxml
, in Debian based systems you'll find libxml2
and libxml2-dev
(use apt-cache search <dependancy>
to find them).
You'll need the libxml2-dev
to build it, and libxml2
to run it.
The ./configure
step usually supports flags like --with-libxml=/usr/lib/
to point it at the correct libraries (./configure --help
should list all of the options). It also usually supports changing the install location with --prefix=$HOME/sw
. Using a prefix outside of what your package manager controls is the best way to avoid conflicts with package manager installed software.
On Debian & derivatives using a --prefix
of /usr/local/
or /opt/local/
should be safe.
If a library (or version) you need isn't available from the package manager just download the source and compile it using similar options. Most importantly use a --prefix
outside of your package manager and when compiling the software you really want use --with-<library>=/<path/to/installed/library>
.
There is the tool auto-apt
which can be used for this.
From man auto-apt:
auto-apt is a program that checks file access of programs running within auto-apt environments. If a program will access a file of unin- stalled package, auto-apt will install the package containing the file, by using apt-get.
It is used as follows:
auto-apt run ./configure
Another way is to use apt-get build-dep <package>
on Debian based distributions.
For RPM based distributions, you could try your hand at creating proper packages (it isn't that hard...).
Benefits of a proper package are that your package manager keeps track of the software, and you can easily replicate your setup elsewhere/on the next machine. With a proper source package porting forward (new upstream version, bugfix patch, underlying libraries get updated) is easier than having to figure it all out from scratch next time.