Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Installation error, libgeos files missing after install #1377

Closed
ConnorDonegan opened this issue Apr 17, 2020 · 11 comments
Closed

Installation error, libgeos files missing after install #1377

ConnorDonegan opened this issue Apr 17, 2020 · 11 comments

Comments

@ConnorDonegan
Copy link

I've been using sf without problems, but tried to install GRASS and QGIS and it must have introduced some issues.

After uninstalling QGIS and GRASS and then some failed attempts to fix this, I manually deleted all /usr/lib/libgeos* files (see below) and I uninstalled all sf dependencies for Ubuntu 18.04. Then I re-installed the sf dependencies with

sudo apt-get install libudunits2-dev libgdal-dev libgeos-dev libproj-dev

I've noticed that /usr/lib/ has

libgdal.so
libgdal.so.26
libgdal.so.26.0.4

but no libgeos* files. They aren't being replaced.

Now library(sf) returns

Error: package or namespace load failed for ‘sf’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/home/connor/repo/R/x86_64-pc-linux-gnu-library/3.6/sf/libs/sf.so':
  libproj.so.15: cannot open shared object file: No such file or directory

and install.packages("sf") gives

/usr/lib/x86_64-linux-gnu/libspatialite.so: undefined reference to `GEOSGeom_getCoordSeq'
collect2: error: ld returned 1 exit status
configure: Install failure: compilation and/or linkage problems.
configure: error: GDALAllRegister not found in libgdal.
ERROR: configuration failed for package ‘rgdal’

I'm thinking its related to this comment:

Yes, multiple libgeos will probably cause havoc. I haven't seen any rgeos issues on Fedora, but always delete earlier /usr/local/lib/libgeos* etc., and never let any packager install GDAL, PROJ or GEOS.

Any advice to get sf working again would be greatly appreciated.

@edzer
Copy link
Member

edzer commented Apr 17, 2020

Do a clean (re-)install of everything.

@ConnorDonegan
Copy link
Author

That is what I've been attempting, is there something you'd add to this?

sudo apt remove libudunits2-dev libgdal-dev libgeos-dev libproj-dev

I've also deleted my installation of sf and rgdal.

Thanks

@edzer
Copy link
Member

edzer commented Apr 18, 2020

What you might have ended up with is different versions of libraries installed at the same time, and not removed after removal of the package needing them; See https://github.com/r-spatial/sf#multiple-gdal-geos-andor-proj-versions-on-your-system

@ConnorDonegan
Copy link
Author

I'm getting closer...I found libgeos_c.so is being installed into /usr/lib/x86_64-linux-gnu/, thank you

With a faint idea of what's going on and carefully copying the file path, I put this into R (following others):

dyn.load('/usr/lib/x86_64-linux-gnu/libgeos_c.so', local=FALSE)

but got

unable to load shared object '/usr/lib/x86_64-linux-gnu/libgeos_c.so':
  /usr/lib/x86_64-linux-gnu/libgeos_c.so: cannot open shared object file: No such file or directory

I moved libgeos_c.so and libgeos_c.a into /usr/lib but that doesn't quite fix it.

The dyn.load call still fails and install.packages("sf") gives:

checking GDAL: linking with --libs only... no
checking GDAL: linking with --libs and --dep-libs... no
/usr/bin/ld: /usr/lib/libgdal.a(genbindataset.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIC

This comment looks promising but I don't know what they are talking about:

Setting the config option --libdir=/usr/lib64 solved all problems and I got clean installs of rgdal and sf.

from #844 (comment)

@edzer
Copy link
Member

edzer commented Apr 18, 2020

That is the usual location, you shouldn't have to do anything to get that found when installing R packages. You may want to try

$ locate libgeos_c.so
/usr/lib/x86_64-linux-gnu/libgeos_c.so
/usr/lib/x86_64-linux-gnu/libgeos_c.so.1
/usr/lib/x86_64-linux-gnu/libgeos_c.so.1.13.1

to find out whether other versions are standing in the way. And similar for GDAL and PROJ.

@ConnorDonegan
Copy link
Author

Maybe this one in /usr/lib/ogdi is the problem:

connor@xps:~$ locate libgdal.so
/usr/lib/ogdi/libgdal.so

But these too?

connor@xps:~$ locate libproj.so
/usr/lib/x86_64-linux-gnu/libproj.so.19
/usr/lib/x86_64-linux-gnu/libproj.so.19.0.0
connor@xps:~$ locate libgeos_c.so
connor@xps:~$

That's after running sudo apt remove and autoremove for these.

Can I just delete those .so files and not worry about any related files?

@ConnorDonegan
Copy link
Author

I deleted the /usr/lib/ogdi/libgdal.so file and started over (apt remove them all, then apt install again) which gives me:

connor@xps:~$ sudo updatedb
connor@xps:~$ locate libproj.so
/usr/lib/x86_64-linux-gnu/libproj.so
/usr/lib/x86_64-linux-gnu/libproj.so.19.0.0
/usr/lib/x86_64-linux-gnu/libproj.so.19.00
connor@xps:~$ locate libgdal.so
/usr/lib/libgdal.so
connor@xps:~$ locate libgeos_c.so
/usr/lib/x86_64-linux-gnu/libgeos_c.so

and I get the same message from GDAL, including:

checking for gdal.h... yes
checking GDAL: linking with --libs only... no
checking GDAL: linking with --libs and --dep-libs... no
/usr/bin/ld: /usr/lib/libgdal.a(genbindataset.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIC

sorry, I really don't know where to go from here. I notice I don't have the same libgeos files you have

@edzer
Copy link
Member

edzer commented Apr 18, 2020

No, they look all good.

@ConnorDonegan
Copy link
Author

well, that's unfortunate cause I'm out of ideas. This won't be much help to others---I re-installed ubuntu to 'fix' it, it was not a bad time for me to do that anyways.

@wibeasley
Copy link
Contributor

This SO comment and blog solved it for me

sudo apt remove libudunits2-dev libgdal-dev libgeos-dev libproj-dev
sudo apt install libudunits2-dev libgdal-dev libgeos-dev libproj-dev libfontconfig1-dev
sudo apt install r-base-dev r-cran-sf r-cran-raster r-cran-rjava
remove.packages("rgdal")
remove.packages("sf")
install.packages("sf")

@fedemolina
Copy link

For the record if you are using conda that coud be the problem (it was in my case) so I use conde deactivate and then the packages were installed witout any problem.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants