[R] rgdal errors from proj

Bennet Fauber bennet @end|ng |rom um|ch@edu
Sat Jun 13 19:13:15 CEST 2020

I am trying to install rgdal from source on CentOS 7.

I have installed geos, proj, and gdal successfully, they test fine.

This is with R version 3.6.3 (2020-02-29) -- "Holding the Windsock"
compiled with gcc/8.2.0.

This is an HPC system, and I have the following modules loaded,

Currently Loaded Modules:
  1) gcc/8.2.0   3) image-libraries/190711.1   5) proj/6.2.1
  2) R/3.6.3     4) geos/3.8.1                 6) gdal/3.1.0

I get the output included below.  In that output, it appears that the
configure correctly identifies the proj options needed from
pkg-config, repeated here

configure: pkg-config proj exists, will use it
configure: PROJ version: 6.2.1
configure: proj CPP flags: -DPROJ_H_API
configure: PROJ LIBS: -L/sw/arcts/centos7/gcc_8_2_0/proj/6.2.1/lib -lproj


$ nm /sw/arcts/centos7/gcc_8_2_0/proj/6.2.1/lib/libproj.so | grep
00000000001ef4e0 T proj_context_create

seems to indicate that is truly there.

I unpacked the rgdal source tar ball and ran ./configure from its
directory and get the same error.  Looking in the generated
config.log, I find

configure:3869: checking for proj_context_create in -lproj
configure:3894: gcc -o conftest -O3 -mtune=native -I/usr/local/include
-DPROJ_H_API -I/sw/arcts/centos7/gcc_8_2_0/proj/6.2.1/include
-L/usr/local/lib64 conftest.c -lproj
-L/sw/arcts/centos7/gcc_8_2_0/gdal/3.1.0/lib -lgdal >&5
/usr/bin/ld: cannot find -lproj

and from that, it appears that configure is not including the correct
CFLAGS to include proj.  It is, instead, putting in
-L/usr/local/lib64, and that is not where the proj libraries are.

Extracting the confdefs.h and conftest.c file from config.log and
running the test compilation command modified by hand to include the
correct library directory for proj,

$ gcc -o conftest -O3 -mtune=native -I/usr/local/include -DPROJ_H_API
-L/sw/arcts/centos7/gcc_8_2_0/proj/6.2.1/lib conftest.c -lproj
-L/sw/arcts/centos7/gcc_8_2_0/gdal/3.1.0/lib -lgdal
$ echo $?

So, I believe there is an error in configure.ac, or in the included
configure script that is not properly registering the library path for
proj.  Note, also, that I get the same result if using

$ ./configure --with-proj-include=/sw/arcts/centos7/gcc_8_2_0/proj/6.2.1/include
    --with-proj-lib=/sw/arcts/centos7/gcc_8_2_0/proj/6.2.1/lib \
. . . .
configure: error: proj_context_create not found in libproj.

Might anyone know what needs to be done to fix this?

Thanks,    -- bennet

Full output of install.packages('rgdal')
> install.packages('rgdal', "/sw/arcts/centos7/Rgeospatial/062020", repo="https:Warning: unable to access index for repository https:repo.miserver.it.umich.edu/cran/src/contrib:
> install.packages('rgdal', "/sw/arcts/centos7/Rgeospatial/062020", repos="https://repo.miserver.it.umich.edu/cran/")
trying URL 'https://repo.miserver.it.umich.edu/cran/src/contrib/rgdal_1.5-10.tar.gz'
Content type 'application/octet-stream' length 2300923 bytes (2.2 MB)
downloaded 2.2 MB

* installing *source* package ‘rgdal’ ...
** package ‘rgdal’ successfully unpacked and MD5 sums checked
** using staged installation
configure: R_HOME: /sw/arcts/centos7/R/3.6.3/lib64/R
configure: CC: gcc
configure: CXX: g++ -std=gnu++11
configure: CXX11 is: g++, CXX11STD is: -std=gnu++11
configure: CXX is: g++ -std=gnu++11
configure: C++11 support available
configure: rgdal: 1.5-10
checking for /usr/bin/svnversion... yes
configure: svn revision: 1006
checking for gdal-config...
checking gdal-config usability... yes
configure: GDAL: 3.1.0
checking GDAL version >= 1.11.4... yes
checking GDAL version <= 2.5 or >= 3.0... yes
checking gdal: linking with --libs only... yes
checking GDAL: gdal-config data directory readable... yes
checking GDAL: /sw/arcts/centos7/gcc_8_2_0/gdal/3.1.0/share/gdal/stateplane.csv
readable... yes
configure: pkg-config proj exists, will use it
configure: PROJ version: 6.2.1
configure: proj CPP flags: -DPROJ_H_API
configure: PROJ LIBS: -L/sw/arcts/centos7/gcc_8_2_0/proj/6.2.1/lib -lproj
checking PROJ header API:... yes
checking for gcc... gcc
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 accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -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 proj.h usability... yes
checking proj.h presence... yes
checking for proj.h... yes
checking for proj_context_create in -lproj... no
configure: error: proj_context_create not found in libproj.
ERROR: configuration failed for package ‘rgdal’

More information about the R-help mailing list