GDAL – How to Re-compile Ogrinfo Against GDAL Used by QGIS

gdalinstallationogrogr2ogrUbuntu

I just solved Repairing broken GDAL and PROJ.4 on Ubuntu? which was blocking use of ogrinfo and ogr2ogr, only to find that these utilities are garbled in one more way: whenever I run any of these, I get following error (this is for ogrinfo, for ogr2ogr it's analogical):

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

I think I understand the cause: I mistakenly installed GDAL 1.9 manually through make-install as suggested here; make-uninstall is not possible for it. Ogrinfo was compiled to this version of GDAL and forgot about version 1.10 shipped with my QGIS (2.10). But I'm stuck here, with no idea how to re-compile ogr against the right version of GDAL.

What I tried:

  • reinstall QGIS (with sudo apt-get --purge autoremove to clean the dependencies after uninstall)
  • trash ogrinfo, ogr2ogr and even whole GDAL-1.9 directory; then I have recovered the ogr files but not gdal 1.9, though I can do it any time
  • few more options like sudo apt-get autoclean

Perhaps I could cleanly purge and install the ogr package if I knew it's exact name. Or do I need to purge the old version completely and then somehow (how?) tell the QGIS installer to install ogr as well?


I searched for all the gdal files on my computer and found that I have files for gdal-1.10 in /usr/bin/ and those for 1.9 in /usr/local/bin/. I manually deleted all the 1.9 files – @evilGenius pointed to this. Now there's just the last step: to point the system to the correct path to the binaries. As /usr/bin/ogrinfo it works perfectly.

Best Answer

You can get GDAL 1.10 from http://download.osgeo.org/gdal/1.10.1/ and compile it the same way as you did with 1.9.

BTW, GDAL 1.11.2 is the current stable version, and installing QGIS on a vanilla lubuntu 15.04 includes that GDAL version. So if you remove (delete the self-compilation and sudo apt-get purge the packages) all GDAL and QGIS stuff, then reinstall QGIS 2.10, you should have it too.

Alternatively, http://packages.ubuntu.com/trusty/gdal-bin should give you the right GDAL package. I guess you removed the wrong (i.e. working) installation with sudo apt-get remove gdal-bin.