7

In ubuntu 12.04, I downloaded the source for a geospatial library, gdal-1.11.0, into ~/src, configured it and compiled it successfully, it seemed. New files such as libgdal.a got put into /usr/local/lib.

However when I run a program that depends on it,

$ ogrinfo --formats

I get

ERROR 1: ogrinfo was compiled against GDAL 1.11 but current library version is 1.10

It seems I haven't removed the older version of GDAL. How should I do that?

Some info about my system:

$ uname -a
Linux ubuntu 3.11.0-15-generic #25~precise1-Ubuntu SMP Thu Jan 30 17:39:31 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

2 Answers2

6

The file libgdal.a will only be used when you link ogrinfo against it without the use of shared libraries. If ogrinfo was linked that way (not using shared libraries), you would not get the error, as the library (version 1.11) would be part of the executable.

What you should try is run

sudo ldconfig

after compiling and installing the new version of gdal, that should inform the system (in which version 1.10 is already loaded as shared library), that a new version is available.

Anthon
  • 79,293
  • I ran sudo ldconfig, then repeated ogrinfo --formats, and I got the same error. – user1416227 Jul 16 '14 at 16:39
  • Can you see, from the output from the compile/install where it copied the new libdalXXXX.so library? You can then try to do export LD_DEBUG=files to see which before starting ogrinfo – Anthon Jul 16 '14 at 17:15
  • I solved my problem (details in comments to @faheem-mitha) by removing old GDAL libraries, recompiling the new GDAL, then running sudo ldconfig as you suggested. – user1416227 Jul 16 '14 at 18:03
  • @user1416227 I'm glad it has been resolved. – Anthon Jul 16 '14 at 18:33
  • This is the correct answer. IF you have old versions of ogr2ogr or GDAL, and installed a new version, for example, by compiling it by HAND, sudo ldconfig should make it point to the new lib and making it work. – George Silva Jul 31 '18 at 18:32
  • This was the solution for me after uninstalling the Debian libgdal-dev package and installing v2.4 from source. Thank you. – ryanjdillon Apr 08 '19 at 09:36
3

It seems I haven't removed the older version of GDAL. How should I do that?

Attempting make uninstall is a reasonable option, if you have kept the sources, which is good practice if you are doing local installs.

A simple alternative is to remove all files relating to this library, both old and new and then reinstall the new one.

However, I have to wonder why you are installing from source when the package is available on Debian, and therefore on Ubuntu. If you are on an older release/version of Ubuntu, and there are no suitable PPAs available, note that backporting from a newer release/version of Ubuntu is possible, and much of the time not difficult.

The listed build dependencies of GDAL 1.11 in Debian are

Build-Depends: debhelper (>= 9), dh-autoreconf, zlib1g-dev, libnetcdf-dev (>= 1:4.0.0), netcdf-bin, libjasper-dev, libpng-dev, libjpeg-dev, libgif-dev, libwebp-dev, libhdf4-alt-dev [!ppc64], libhdf5-dev (>= 1.8.8), libpcre3-dev, libpq-dev, libxerces-c-dev, unixodbc-dev (>= 2.2.11), doxygen, d-shlibs, libgeos-dev, libmysqlclient-dev, dh-python, python-all-dev (>= 2.6.6-3~), python-numpy, python3-all-dev, python3-numpy, libcurl4-gnutls-dev | libcurl-ssl-dev, libsqlite3-dev, libogdi3.2-dev, chrpath, swig, patch, libexpat1-dev, libproj-dev, libdap-dev, libxml2-dev, libspatialite-dev (>= 2.4.0~rc2-4), libepsilon-dev (>= 0.9.1-1~), libpoppler-private-dev, liblzma-dev, libopenjpeg-dev, libarmadillo-dev, libfreexl-dev (>= 1.0.0), libkml-dev (>= 1.3.0~), liburiparser-dev, default-jdk, ant

which doesn't look too bad. To be clear, the idea here is to rebuild Debian/Ubuntu sources on your release. If you want tips or more details, I can elaborate.

Here are the versions of GDAL available in Debian.

$ apt-cache policy libgdal1-dev
libgdal1-dev:
  Installed: (none)
  Candidate: 1.9.0-3.1
  Version table:
     1.11.0+dfsg1-1~exp2 0
          1 http://debian.lcs.mit.edu/debian/ experimental/main amd64 Packages
     1.10.1+dfsg-6 0
         50 http://debian.lcs.mit.edu/debian/ testing/main amd64 Packages
         50 http://debian.lcs.mit.edu/debian/ unstable/main amd64 Packages
     1.9.0-3.1 0
        500 http://debian.lcs.mit.edu/debian/ wheezy/main amd64 Packages
     1.6.3-4+b1 0
        500 http://debian.lcs.mit.edu/debian/ squeeze/main amd64 Packages
Faheem Mitha
  • 35,108
  • I need to install from source because I want to include support for FileGDB (maybe more than you want to know but before make I run configure --with-fgdb=/usr/local/FileGDB_API --with-pg=/usr/bin/pg_config). However, the 1.10 version was not compiled by me, I did it the easy way and just fetched it with apt-get, or perhaps it was fetched as a dependency, I don't remember. Considering that, if I run make uninstall, that won't uninstall the 1.10 version, will it? You suggest "remove all files relating to this library." Which files are those? – user1416227 Jul 16 '14 at 16:32
  • You don't need to install from source to do that. Just change the command that debian uses for compilation. You can find it in the file debian/rules. – Faheem Mitha Jul 16 '14 at 16:35
  • This would have the unfortunate side-effect that you will have a binary system package depending on a locally installed package, but I won't tell anyone if you don't. – Faheem Mitha Jul 16 '14 at 16:42
  • Interesting. Where do I find the file, debian/rules? – user1416227 Jul 16 '14 at 16:42
  • Well, the first step in to unpack the Debian sources. Once you have done that, you will find the debian directory in there, and this directory contains the rules file. It is essentially a makefile. – Faheem Mitha Jul 16 '14 at 16:55
  • 2
    Okay. I have taken your simplest suggestion which is to "remove all the files relating to the library then reinstall." So I successfully ran these commands, which eliminated the error: First, $ sudo apt-get remove python-gdal python3-gdal libgdal1h libgdal1-dev libgdal-perl libgdal-java libgdal-doc libgdal-dev gdal-bin Then $ sudo make install of the source code for gdal-1.11.0 and $ sudo ldconfig Subsequently $ ogrinfo --formats produced no error. As for the longish list of packages I had to remove, I found those at https://packages.debian.org/source/sid/gdal – user1416227 Jul 16 '14 at 17:43