Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 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)

share|improve this question

migrated from Oct 26 '12 at 5:57

This question came from our site for professional and enthusiast programmers.

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?) – Oct 26 '12 at 0:02
1 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. – Ari B. Friedman Oct 26 '12 at 0:11
Did you look whether you could get r-cran-rgdal via Michael's PPA? – Dirk Eddelbuettel Oct 26 '12 at 0:18 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 – radek Oct 26 '12 at 0:27
up vote 16 down vote accepted

A more recent answer can be found here: .

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!

share|improve this answer
Had a problem with rgdal one more time... and stumble upon my own question here. This time your solution solved the issue. – radek Apr 24 '15 at 15:50
It is useful. Thank you so much for taking the time to record these steps. – Josh O'Brien Jan 22 at 0:05
sudo apt-get install r-cran-rgdal # this command also does it and installs the dependencies automatically – RobinLovelace Feb 1 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.

share|improve this answer
Thanks - that seemed to do the trick. Will future updates cause some conflict with such solution? – radek Nov 1 '12 at 17:30
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 Nov 6 '12 at 2:15

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
share|improve this answer

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)

share|improve this answer
Thanks. I tried your solution (autoremove did not kick out anything) - unfortunately it didn't help. – radek Oct 26 '12 at 11:10
It removes if any unnecessary package, sometimes It becomes important to remove it when your system has it. – K.K Patel Oct 26 '12 at 11:14

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"))'
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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