I'm a relatively new Ubuntu server user, so I'm learning as I go. I have an issue with a software package I'm installing (QGIS) which has several dependencies one of them being gdal library. Regardless of the installation manager I use (apt, synaptic or aptitude), this package installs gdal version 1.7.3 which is quite outdated (current stable is 1.9.1). I wouldn't have an issue with this if I hadn't already built/compiled the last version of gdal myself (I chose to do so, so I could include some uncommon raster format support).

If I type dpkg --list, I can see both libraries existing one beside the other but I don't even want the old one. After some tinkering I used synaptic and manually disabled gdal dependency during installation and then my compiled version of gdal 1.9.1 kicked in. Why wouldn't QGIS use the last version from the start?

Also, is there a way in Linux to check whether dependencies need to be installed at all? Or perhaps, is there a way to change which libraries certain package uses after it's been installed?


Each deb package have list of dependencies that should be met before installation. You can list dependencies of deb file using dpkg --info path_to.deb. Here is the example:

 new debian package, version 2.0.
 size 5800810 bytes: control archive=2527 bytes.
    1301 bytes,    20 lines      control              
    3074 bytes,    41 lines      md5sums              
     721 bytes,    22 lines   *  postinst             #!/bin/sh
     637 bytes,    18 lines   *  postrm               #!/bin/sh
 Package: qgis
 Version: 1.8.0~precise1
 Architecture: i386
 Maintainer: Quantum GIS developers <qgis-developer@lists.osgeo.org>
 Installed-Size: 10374
 Depends: libc6 (>= 2.4), libgcc1 (>= 1:4.1.1), libgdal1-1.7.0, libgsl0ldbl (>= 1.9), libpq5, libproj0, libqgis1.8.0, libqt4-network (>= 4:4.5.3), libqt4-sql (>= 4:4.5.3), libqt4-svg (>= 4:4.5.3), libqt4-xml (>= 4:4.5.3), libqtcore4 (>= 4:4.8.0), libqtgui4 (>= 4:4.8.0), libqtwebkit4 (>= 2.2~2011week36), libqwt5-qt4, libspatialite3 (>= 3.0.0~beta20110817), libsqlite3-0 (>= 3.5.9), libstdc++6 (>= 4.6), qgis-providers (= 1.8.0~precise1), qgis-common (= 1.8.0~precise1)
 Recommends: qgis-plugin-globe, qgis-plugin-grass, python-qgis
 Suggests: gpsbabel
 Conflicts: uim-qt3
 Section: science
 Priority: extra
 Homepage: http://qgis.org/
 Description: Geographic Information System (GIS)
  A Geographic Information System (GIS) manages, analyzes, and displays
  databases of geographic information. Quantum GIS (QGIS) supports shape file
  viewing and editing, spatial data storage with PostgreSQL/PostGIS, projection
  on-the-fly, map composition, and a number of other features via a plugin
  interface. QGIS also supports display of various georeferenced raster and
  Digital Elevation Model (DEM) formats including GeoTIFF, Arc/Info ASCII Grid,

Most important for you is section "Depends" contains a list of packages and their version that must be installed to install your package. For each package may be information about exact version, minimal version or maximal version.

As you can see above qgis requires libgdal1-1.7.0 (it's name not version). Current version of this package in Ubuntu repo is 1.7.3-6ubuntu3 (notice that minimal version of package is not provided!).

When you compile that lib from sources (./configure && make && make install or something like that) you put binaries of that package in system directories. But when you installing package via apt, synaptic or aptitude they don't care about binaries. They're using installed packages index (somewhere in /var/) and they don't know that you installed that library from sources, so they're installing all dependencies. To make that tools aware that there is gdal in system you could prepare deb package from compiled source code and install it using dpkg. There should be some tutorial about that on Debian's wiki. But even when you prepare such package package management tools still will be looking for package with name libgdal1-1.7.0 (of course you could prepare package with gdal 1.9.1 and name it libgdal1-1.7.0, but it's not good idea - there could be some API changes in newer version and it is possible that qgis will crash or something like this).

Why qgis is using old gdal?

Ubuntu have long release cycle, so when package repo was freezed it could be better idea for some reasons to use older version of this package. Or maybe there is no one willing to prepare new version? ;)

Is there a way to change dependency list?

Yes. You can download selected package and repack it with changed dependency list:

mkdir tmp
dpkg -x package.deb ./tmp
dpkg -e package.deb

nano ./tmp/DEBIAN/control and change dependency list
mkdir ./build
dpkg-deb -b ./tmp ./build

You can do that, but there is a chance that you will have some problems in future with installing software because of inconsistency in global installed packages list.


Sometimes compiling a newer version from source is the only possible solution to a problem but, as a general rule, it is best to avoid it unless it is absolutely necessary. Bypassing the package system usually means gaining a short-term fix for a lot of long-term pain. And if you compile and install a newer version of gdal into, say, /usr/local then you should compile gqis as well.

A better question would be: "Where can I get a newer gdal library package for Ubuntu?" followed by "and where can I get a gqis package for Ubuntu compiled to use it?"

The answer to both these questions is that newer versions of both are packaged in the up-coming 'quantal' version of Ubuntu, due to be released in about a month. Currently, quantal has the following versions (but this is likely to change by the time it is released)

http://packages.ubuntu.com/quantal/qgis (1.7.4+1.7.5~20120320-1.1)
http://packages.ubuntu.com/quantal/libgdal1 (1.9.0-3ubuntu3)

It is possible to configure apt so that it knows about packages from both Ubuntu Precise and Ubuntu Quantal, but to prefer packages from Precise by default. This would allow you to force the quantal versions of certain packages to be installed.

Search here or on sister sites like https://askubuntu.com/ for "APT Pinning" for details on how to do this - https://askubuntu.com/questions/103320/install-packages-from-newer-release-without-building-apt-pinning for example.

Note that installing newer packages from a newer version of Ubuntu like this may cause other packages to be upgraded, even if you didn't specify them - if a package you want installed depends on newer versions of other packages, then the only way to satisfy those dependencies is to install them too.

Another alternative is to backport - i.e. download the debianised sources for libgdal1 and gqis from Quantal and recompile the packages for Precise. This may involve downloading and recompiling source packages for any other packages that those two depend upon (and in turn, those extra packages may also have updated dependancies that need recompiling...and so on). It's generally a lot more work to backport packages like this than it is to use apt pinning.

  • Thanks for the thorough explanation to both of you guys. I thought about compiling every single dependancy from source, but qgis had so many i kind of gave up on that idea hehe. Its sometimes confusing finding the right repository with the right packages/versions. Btw... if a certain package i found in 2 repositories... which one is prefered over the other? – U2ros Sep 12 '12 at 8:08
  • That's what pinning is for - to define which one is preferred. – cas Sep 12 '12 at 8:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.