23

Im trying to install a package named "rgeos" on R 3.3, but when I type

install.packages("rgeos")

But it returns me the following error (same happens with other packages, but not all the packages):

> * installing *source* package ‘rgeos’ ...
** package ‘rgeos’ successfully unpacked and MD5 sums checked
configure: CC: gcc
configure: CXX: g++
configure: rgeos: 0.3-19
checking for /usr/bin/svnversion... no
configure: svn revision: 524
checking for geos-config... no
no
configure: error: geos-config not found or not executable.
ERROR: configuration failed for package ‘rgeos’
* removing ‘/home/kdg/R/x86_64-pc-linux-gnu-library/3.3/rgeos’
> 
> The downloaded source packages are in
>   ‘/tmp/Rtmpsa5pDo/downloaded_packages’ Warning message: In
> install.packages("rgeos") :   installation of package ‘rgeos’ had
> non-zero exit status

Any clues how con install this package?

user20650
  • 21,689
  • 5
  • 46
  • 77
Tangent3
  • 953
  • 1
  • 7
  • 13

2 Answers2

37

It seems that when running R in Linux is necessary to install some build tools. As in this case, in the terminal:

sudo apt-get install libgeos-dev

Then try package install again.

hints from here

Community
  • 1
  • 1
Tangent3
  • 953
  • 1
  • 7
  • 13
  • If you are on Centos I suggest you to follow: https://stackoverflow.com/questions/42097501/centos-libgeos-repository-missing?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa instead – Ale May 14 '18 at 10:26
  • 4
    As an alternative: `sudo apt-get install libgeos++-dev` – SRhm Oct 20 '18 at 02:27
  • 1
    @SRhm, you are right. After upgrading to R 3.5, to install rgeos i had to install `ibgeos++-dev` also. Thanks – Sergio Oct 22 '18 at 15:39
0

I solved it with the following:

cd /opt
git clone https://github.com/libgeos/geos
cd geos
export CC='clang' && export CXX='clang++' && export OBJC='clang'
./autogen.sh
./configure
make
sudo -EH make install
R
install.packages('rgeos')

NB: export clang is particular to me; I am just pasting my exact solution.

isomorphismes
  • 7,610
  • 9
  • 53
  • 69