I'm strugling to install rgdal library on Ubuntu 12.10.

Installation from within R results in error:

Error: gdal-config not found The gdal-config script distributed with GDAL could not be found. If you have not installed the GDAL libraries, you can download the source from http://www.gdal.org/ If you have installed the GDAL libraries, then make sure that gdal-config is in your path. Try typing gdal-config at a shell prompt and see if it runs. If not, use: --configure-args='--with-gdal-config=/usr/local/bin/gdal-config' with appropriate values for your installation.

ERROR: configuration failed for package ‘rgdal’ * removing ‘/home/rdk/R/x86_64-pc-linux-gnu-library/2.15/rgdal’ Warning in install.packages : installation of package ‘rgdal’ had non-zero exit status

R-sig-Geo, this two SE questions and other websites pointed me to the requirements of libgdal1-dev.

But when I tried

sudo apt-get install libgdal1-dev

I end up with another error message

Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation:

The following packages have unmet dependencies: libgdal1-dev : Depends: libgdal-dev but it is not going to be installed E: Unable to correct problems, you have held broken packages.

Again - when I try to install libgdal-dev another dependencies error shows up

The following packages have unmet dependencies: libgdal-dev : Depends: libgeos-dev but it is not going to be installed Depends: libspatialite-dev but it is not going to be installed

Again trying libgeos-dev gives message:

Depends: libgeos-c1 (= 3.3.3-1.1) but 3.3.3-2~precise2 is to be installed
E: Unable to correct problems, you have held broken packages.

and libspatialite-dev:

Depends: libspatialite3 (= 3.1.0~rc2-1ubuntu1) but
3.1.0~rc2-2~precise1 is to be installed

Is there any way to tame those dependencies and have rgdal running in Ubuntu?

My sessionInfo()

R version 2.15.1 (2012-06-22) Platform: x86_64-pc-linux-gnu (64-bit)

  • 1
    On Ubuntu 12.04 installing libgdal-dev & libgdal1-dev worked fine - perhaps it is because Quantal (12.10) is quite new and the package maintainers haven't updated the right versions yet? (Actually, why is it saying it is going to install 3.3.3-2~precise2 when you are on quantal?) Commented Oct 26, 2012 at 0:02
  • 1
    @mathematical.coffee Is correct. I did this on QQbeta2 a few weeks ago, but I can't remember how. Try setting the CRAN repository in /etc/apt/sources.list to precise rather than quantal. Commented Oct 26, 2012 at 0:11
  • 2
    Did you look whether you could get r-cran-rgdal via Michael's PPA? Commented Oct 26, 2012 at 0:18
  • mathematical.coffee: Might as well be tad too early then. Ari: I updated CRAN repo - thanks for the tip. Dirk: Pardon my ignorance - are we talking about launchpad.net/~marutter/+archive/c2d4u
    – user26243
    Commented Oct 26, 2012 at 0:27
  • @radek given Josh O'Brien's answer below for 14.04, it may be worth editing your question to make it more general for other Ubuntu releases. I think it'd be useful to have a canonical question for this.
    – amc
    Commented Sep 23, 2016 at 15:11

5 Answers 5


A more recent answer can be found here: http://robinlovelace.net/r/2013/11/26/installing-rgdal-on-ubuntu.html .

Essentially, the three following lines of code should sort it:

sudo apt-get install aptitude # install aptitude as an alternative to apt-get
sudo aptitude install libgdal-dev # install the package (you may have to respond to queries here)
sudo aptitude install libproj-dev # install the proj.4 projection library

Spent ages on this problem, so hope this updated answer is useful to others. Let me know if so!

  • Had a problem with rgdal one more time... and stumble upon my own question here. This time your solution solved the issue.
    – user26243
    Commented Apr 24, 2015 at 15:50
  • It is useful. Thank you so much for taking the time to record these steps. Commented Jan 22, 2016 at 0:05
  • 1
    sudo apt-get install r-cran-rgdal # this command also does it and installs the dependencies automatically Commented Feb 1, 2016 at 22:48

Try running them all together and specifying the versions, like this:

sudo apt-get install libgdal1-dev libgdal-dev libgeos-c1=3.3.3-1.1 libspatialite3=3.1.0~rc2-1ubuntu1

apt-get does not like to downgrade packages, but it will if you specify it.

  • Thanks - that seemed to do the trick. Will future updates cause some conflict with such solution?
    – user26243
    Commented Nov 1, 2012 at 17:30
  • 2
    They may likely cause upgrade problems, yes. To prevent a package from being upgraded, run this for every package: echo packagename hold | sudo dpkg --set-selections
    – Rucent88
    Commented Nov 6, 2012 at 2:15

Here in January 2016, on Ubuntu 14.04.2 (and with R 3.2.2), I needed the following to get both rgdal and the complementary (and frequently very useful) gdalUtils package installed:

sudo apt-get update
sudo apt-get -y install libgdal1h
sudo apt-get -y install libgdal1-dev
sudo apt-get install libproj-dev
sudo apt-get install gdal-bin
Rscript 'install.packages(c("rgdal", "gdalUtils"))'

Update: As on January 2017, the version of libgdal is 1i, so the second line of code should read:

sudo apt-get -y install libgdal1i

Open terminal by pressing (Ctrl+alt+T) and type following command.

sudo apt-get update

sudo apt-get install -f

(It will fix dependencies.)

sudo apt-get autoremove

(removing Unnecessary packages)

sudo apt-get clean

(Clear cache)

  • Thanks. I tried your solution (autoremove did not kick out anything) - unfortunately it didn't help.
    – user26243
    Commented Oct 26, 2012 at 11:10
  • 1
    It removes if any unnecessary package, sometimes It becomes important to remove it when your system has it.
    – KK Patel
    Commented Oct 26, 2012 at 11:14

To get rgdal to install on Ubuntu 12.04, I had to install (and hold) many version specific packages. Basically I tried each package and installed the required versions of the dependencies until I could work back up to the original goal, to install libgdal1-dev

sudo apt-get install libspatialite3=3.0.0~beta20110817-3
echo libspatialite3 hold | sudo dpkg --set-selections
sudo apt-get install libspatialite-dev
sudo apt-get install libgeos-c1=3.3.3-1.1~pgdg12.4+1
echo libgeos-c1 hold | sudo dpkg --set-selections
sudo apt-get install libgdal1=1.9.0-3.1~pgdg12.4+1
echo libgdal1 hold | sudo dpkg --set-selections

sudo apt-get install libgdal-dev
sudo apt-get install libgdal1-dev
gdal-config # now works, and can now install rgdal

You must log in to answer this question.