Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Unable to install package sf on Ubuntu 20.04 #1685

Closed
lionelvoirol opened this issue Jun 3, 2021 · 19 comments
Closed

Unable to install package sf on Ubuntu 20.04 #1685

lionelvoirol opened this issue Jun 3, 2021 · 19 comments

Comments

@lionelvoirol
Copy link

lionelvoirol commented Jun 3, 2021

Hi,
I am trying to install sf on a Ubuntu 20.04 installation.
I know that sf require the combination of GEOS, GDAL and Proj.4 to be installed.
I have installed all of these package following the instructions provided in the GitHub README.
Indeed,

sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update
sudo apt-get install libudunits2-dev libgdal-dev libgeos-dev libproj-dev 

returns:

libudunits2-dev is already the newest version (2.2.26-5).
libgdal-dev is already the newest version (3.2.1+dfsg-1~focal0).
libgeos-dev is already the newest version (3.9.0-1~focal0).
libgeos-dev set to manually installed.
libproj-dev is already the newest version (7.2.1-1~focal0).

I know that ensuring the proper interaction of these three libraries is particularly difficult on Linus because I've read the multiple issues and discussions about installing sf on Linux distros and I've spent days trying different approach and solutions. I am unable to succeed and I'm looking for some help to be able to install these libraries and install sf on my Ubuntu 20.04 installation. Could someone give me a hand please?

Here is the results in R of install.packages("sf"):

Installing package into ‘/home/lionel/R/x86_64-pc-linux-gnu-library/4.0’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/sf_0.9-8.tar.gz'
Content type 'application/x-gzip' length 4213253 bytes (4.0 MB)
==================================================
downloaded 4.0 MB

* installing *source* package ‘sf’ ...
** package ‘sf’ successfully unpacked and MD5 sums checked
** using staged installation
configure: CC: gcc -std=gnu99
configure: CXX: g++ -std=gnu++11
checking for gdal-config... /usr/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 3.2.1
checking GDAL version >= 2.0.1... yes
checking for gcc... gcc -std=gnu99
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -std=gnu99 accepts -g... yes
checking for gcc -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -std=gnu99 -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking gdal.h usability... yes
checking gdal.h presence... yes
checking for gdal.h... yes
checking GDAL: linking with --libs only... yes
checking GDAL: /usr/share/gdal/pcs.csv readable... no
checking GDAL: checking whether PROJ is available for linking:... yes
checking GDAL: checking whether PROJ is available fur running:... yes
configure: GDAL: 3.2.1
configure: pkg-config proj exists, will use it
configure: using proj.h.
configure: PROJ: 7.2.1
checking PROJ: checking whether PROJ and sqlite3 are available for linking:... no
configure: error: libproj or sqlite3 not found in standard or given locations.
ERROR: configuration failed for package ‘sf’
* removing ‘/home/lionel/R/x86_64-pc-linux-gnu-library/4.0/sf’
Warning in install.packages :
  installation of package ‘sf’ had non-zero exit status

The downloaded source packages are in
	‘/tmp/RtmpkJvTL0/downloaded_packages’

and here is my session info:

> sessionInfo()
R version 4.0.5 (2021-03-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.2 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_CA.UTF-8       
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_CA.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_CA.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] fansi_0.4.2      assertthat_0.2.1 utf8_1.1.4       crayon_1.4.1    
 [5] dplyr_1.0.4      R6_2.5.0         DBI_1.1.1        lifecycle_1.0.0 
 [9] magrittr_2.0.1   pillar_1.5.0     rlang_0.4.11     debugme_1.1.0   
[13] vctrs_0.3.6      generics_0.1.0   ellipsis_0.3.1   tools_4.0.5     
[17] glue_1.4.2       purrr_0.3.4      compiler_4.0.5   pkgconfig_2.0.3 
[21] tidyselect_1.1.0 tibble_3.1.0    

Could someone please give me a hand for this installation, I am a little bit desperate.

Thanks & Best

Lionel

@lionelvoirol lionelvoirol changed the title Unable to install and use package sf on Ubuntu 20.04 Unable to install package sf on Ubuntu 20.04 Jun 3, 2021
@edzer
Copy link
Member

edzer commented Jun 3, 2021

Did you install ubuntu package libsqlite3-dev?

@lionelvoirol
Copy link
Author

Hi,
Yes it is already installed:

sudo apt-get install libsqlite3-dev              
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libsqlite3-dev is already the newest version (3.31.1-4ubuntu0.2).
libsqlite3-dev set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

@edzer
Copy link
Member

edzer commented Jun 3, 2021

Is there more than one version of PROJ installed on your box, e.g. in /usr/local/lib?

@lionelvoirol
Copy link
Author

lionelvoirol commented Jun 3, 2021

Hi,

I am not sure how to find all version of PROJ installed.
I tried this:

locate libproj.so
/usr/lib/x86_64-linux-gnu/libproj.so
/usr/lib/x86_64-linux-gnu/libproj.so.15
/usr/lib/x86_64-linux-gnu/libproj.so.15.3.1

and that:

apt-cache pkgnames libproj   
libproj-dev
libprojectm-dev
libprojectm2v5
libproj15
libproj19

How should I proceed?

Thanks !

@edzer
Copy link
Member

edzer commented Jun 3, 2021

I don't know; I use the same setup, and see the same for the apt-cache command, but see

locate libproj.so
/usr/lib/x86_64-linux-gnu/libproj.so
/usr/lib/x86_64-linux-gnu/libproj.so.19
/usr/lib/x86_64-linux-gnu/libproj.so.19.2.1

so maybe that is a problem. Maybe remove and reinstall PROJ? (Is this an incremental update from ubuntu 18.04?)

@lionelvoirol
Copy link
Author

Hey,

After looking at the installed packages with apt, I removed libproj-dev:amd64 with

sudo apt-get remove libproj-dev:amd64   

and installed libproj19 with

sudo apt-get install libproj19 

after updating the database of locate I have

locate libproj.so                    
/usr/lib/x86_64-linux-gnu/libproj.so.19
/usr/lib/x86_64-linux-gnu/libproj.so.19.2.1

After trying to install sf again with install.packages("sf"), I still have an error message, but different this time, that concerns gdal-config :

> install.packages("sf")
Installing package into ‘/home/lionel/R/x86_64-pc-linux-gnu-library/4.0’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/sf_0.9-8.tar.gz'
Content type 'application/x-gzip' length 4213253 bytes (4.0 MB)
==================================================
downloaded 4.0 MB

* installing *source* package ‘sf’ ...
** package ‘sf’ successfully unpacked and MD5 sums checked
** using staged installation
configure: CC: gcc -std=gnu99
configure: CXX: g++ -std=gnu++11
checking for gdal-config... no
no
configure: error: gdal-config not found or not executable.
ERROR: configuration failed for package ‘sf’
* removing ‘/home/lionel/R/x86_64-pc-linux-gnu-library/4.0/sf’
Warning in install.packages :
  installation of package ‘sf’ had non-zero exit status

The downloaded source packages are in
	‘/tmp/RtmpkJvTL0/downloaded_packages’

Any idea?

I have installed installed Ubuntu 20.04, so I imagine that this not an incremental update from Ubuntu 18.04 (?)

@lionelvoirol
Copy link
Author

lionelvoirol commented Jun 3, 2021

I followed this thread and executed sudo apt install libgdal-dev. I now have:

▶ locate libgdal.so
/usr/lib/libgdal.so
/usr/lib/libgdal.so.28
/usr/lib/libgdal.so.28.0.1
/usr/lib/ogdi/libgdal.so

Now when I try to install sf I have:

install.packages("sf")
Installing package into ‘/home/lionel/R/x86_64-pc-linux-gnu-library/4.0’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/sf_0.9-8.tar.gz'
Content type 'application/x-gzip' length 4213253 bytes (4.0 MB)
==================================================
downloaded 4.0 MB

* installing *source* package ‘sf’ ...
** package ‘sf’ successfully unpacked and MD5 sums checked
** using staged installation
configure: CC: gcc -std=gnu99
configure: CXX: g++ -std=gnu++11
checking for gdal-config... /usr/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 3.2.1
checking GDAL version >= 2.0.1... yes
checking for gcc... gcc -std=gnu99
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -std=gnu99 accepts -g... yes
checking for gcc -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -std=gnu99 -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking gdal.h usability... yes
checking gdal.h presence... yes
checking for gdal.h... yes
checking GDAL: linking with --libs only... yes
checking GDAL: /usr/share/gdal/pcs.csv readable... no
checking GDAL: checking whether PROJ is available for linking:... yes
checking GDAL: checking whether PROJ is available fur running:... yes
configure: GDAL: 3.2.1
configure: pkg-config proj exists, will use it
configure: using proj.h.
configure: PROJ: 7.2.1
checking PROJ: checking whether PROJ and sqlite3 are available for linking:... no
configure: error: libproj or sqlite3 not found in standard or given locations.
ERROR: configuration failed for package ‘sf’
* removing ‘/home/lionel/R/x86_64-pc-linux-gnu-library/4.0/sf’
Warning in install.packages :
  installation of package ‘sf’ had non-zero exit status

The downloaded source packages are in
	‘/tmp/RtmpkJvTL0/downloaded_packages’

@edzer
Copy link
Member

edzer commented Jun 4, 2021

Maybe remove all of gdal, geos and proj in a single action, and then reinstall all of them as in the readme.

@lionelvoirol
Copy link
Author

Allright, so I have uninstalled all installed versions of gdal, geos and proj with

sudo apt-get remove libproj-dev:amd64 
sudo apt-get remove libproj19:amd64 
sudo apt-get remove libgeos-dev
sudo apt-get remove libgeos-3.9.0:amd64 
sudo apt-get remove libgdal-dev

and I obtain

locate libproj.so
locate libgeos.so
locate libgdal.so

that do not returns anything.

I then reinstalled them with:

sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update
sudo apt-get install libudunits2-dev libgdal-dev libgeos-dev libproj-dev

After updating the `locate``databse, I now have:

 lionel@lionel-pc 
▶ locate libproj.so
/usr/lib/x86_64-linux-gnu/libproj.so
/usr/lib/x86_64-linux-gnu/libproj.so.19
/usr/lib/x86_64-linux-gnu/libproj.so.19.2.1
 lionel@lionel-pc 
▶ locate libgeos.so
 lionel@lionel-pc 
▶ locate libgdal.so                                       
/usr/lib/libgdal.so
/usr/lib/libgdal.so.28
/usr/lib/libgdal.so.28.0.1
/usr/lib/ogdi/libgdal.so

When I then try to install sf, I have:

install.packages("sf")
Installing package into ‘/home/lionel/R/x86_64-pc-linux-gnu-library/4.0’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/sf_0.9-8.tar.gz'
Content type 'application/x-gzip' length 4213253 bytes (4.0 MB)
==================================================
downloaded 4.0 MB

* installing *source* package ‘sf’ ...
** package ‘sf’ successfully unpacked and MD5 sums checked
** using staged installation
configure: CC: gcc -std=gnu99
configure: CXX: g++ -std=gnu++11
checking for gdal-config... /usr/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 3.2.1
checking GDAL version >= 2.0.1... yes
checking for gcc... gcc -std=gnu99
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -std=gnu99 accepts -g... yes
checking for gcc -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -std=gnu99 -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking gdal.h usability... yes
checking gdal.h presence... yes
checking for gdal.h... yes
checking GDAL: linking with --libs only... yes
checking GDAL: /usr/share/gdal/pcs.csv readable... no
checking GDAL: checking whether PROJ is available for linking:... yes
checking GDAL: checking whether PROJ is available fur running:... yes
configure: GDAL: 3.2.1
configure: pkg-config proj exists, will use it
configure: using proj.h.
configure: PROJ: 7.2.1
checking PROJ: checking whether PROJ and sqlite3 are available for linking:... no
configure: error: libproj or sqlite3 not found in standard or given locations.
ERROR: configuration failed for package ‘sf’
* removing ‘/home/lionel/R/x86_64-pc-linux-gnu-library/4.0/sf’
Warning in install.packages :
  installation of package ‘sf’ had non-zero exit status

The downloaded source packages are in
	‘/tmp/RtmpX40ZWz/downloaded_packages’

@edzer
Copy link
Member

edzer commented Jun 4, 2021

Could you save this:

#include <stdio.h>
#include <stdlib.h>
#include <proj.h>

int main() {
    proj_context_create();
    exit(0);
}

to a file called proj_test.cpp, compile it with

g++ -o proj_test proj_test.cpp -lproj -lsqlite3

and let us know what you see? Can you execute the program with

./proj_test

?

@lionelvoirol
Copy link
Author

Hey,

So I just save and tried to compile the proj_test.cpp file with g++ -o proj_test proj_test.cpp -lproj -lsqlite3 and I get this

▶ g++ -o proj_test proj_test.cpp -lproj -lsqlite3
/home/linuxbrew/.linuxbrew/bin/ld: /lib/x86_64-linux-gnu/libcurl-gnutls.so.4: undefined reference to `gnutls_srp_free_client_credentials@GNUTLS_3_4'
/home/linuxbrew/.linuxbrew/bin/ld: /lib/x86_64-linux-gnu/libcurl-gnutls.so.4: undefined reference to `gnutls_srp_allocate_client_credentials@GNUTLS_3_4'
/home/linuxbrew/.linuxbrew/bin/ld: /lib/x86_64-linux-gnu/libcurl-gnutls.so.4: undefined reference to `gnutls_srp_set_client_credentials@GNUTLS_3_4'
collect2: error: ld returned 1 exit status

So proj_test is not defined and I can not execute it.

@edzer
Copy link
Member

edzer commented Jun 4, 2021

/home/linuxbrew/.linuxbrew/bin/ld:

Looks like you have some funny custom compiler setup. I think that's where my ability to support stops.

@lionelvoirol
Copy link
Author

lionelvoirol commented Jun 4, 2021

Okay, I just reinstalled g++ and ran g++ -o proj_test proj_test.cpp -lproj -lsqlite3

This time it worked without errors and created proj_test.

I then executed proj_test with ./proj_test but this does not produce any output.

Any idea on what is this indicating?

Thanks!

@edzer
Copy link
Member

edzer commented Jun 4, 2021

That is fine. Can you install sf?

@lionelvoirol
Copy link
Author

Unfortunately no, I still have

> install.packages("sf")
Installing package into ‘/home/lionel/R/x86_64-pc-linux-gnu-library/4.0’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/sf_0.9-8.tar.gz'
Content type 'application/x-gzip' length 4213253 bytes (4.0 MB)
==================================================
downloaded 4.0 MB

* installing *source* package ‘sf’ ...
** package ‘sf’ successfully unpacked and MD5 sums checked
** using staged installation
configure: CC: gcc -std=gnu99
configure: CXX: g++ -std=gnu++11
checking for gdal-config... /usr/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 3.2.1
checking GDAL version >= 2.0.1... yes
checking for gcc... gcc -std=gnu99
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -std=gnu99 accepts -g... yes
checking for gcc -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -std=gnu99 -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking gdal.h usability... yes
checking gdal.h presence... yes
checking for gdal.h... yes
checking GDAL: linking with --libs only... yes
checking GDAL: /usr/share/gdal/pcs.csv readable... no
checking GDAL: checking whether PROJ is available for linking:... yes
checking GDAL: checking whether PROJ is available fur running:... yes
configure: GDAL: 3.2.1
configure: pkg-config proj exists, will use it
configure: using proj.h.
configure: PROJ: 7.2.1
checking PROJ: checking whether PROJ and sqlite3 are available for linking:... no
configure: error: libproj or sqlite3 not found in standard or given locations.
ERROR: configuration failed for package ‘sf’
* removing ‘/home/lionel/R/x86_64-pc-linux-gnu-library/4.0/sf’
Warning in install.packages :
  installation of package ‘sf’ had non-zero exit status

The downloaded source packages are in
	‘/tmp/RtmpOExq35/downloaded_packages’

@edzer
Copy link
Member

edzer commented Jun 4, 2021

Well, I'm sure you could if you had a regular setup. Sorry, but closing here.

@edzer edzer closed this as completed Jun 4, 2021
@lionelvoirol
Copy link
Author

Allright. No necessary clear what do you mean by a regular setup. Thanks for the help.

@rsbivand
Copy link
Member

rsbivand commented Jun 5, 2021

Had you searched the issues with "Ubuntu 20.04" as the key word, you would have found this thread and concluding resolution: #1628 (comment). Searching issues very often leads to resolution without using developer time.

@hendrohwibowo
Copy link

hendrohwibowo commented Mar 20, 2022

this solve my problem installing sf in Ubuntu 20.04:
https://philmikejones.me/tutorials/2018-08-29-install-sf-ubuntu.html

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

No branches or pull requests

4 participants