[R-sig-Geo] rgdal configure errors for proj test
Bennet Fauber
bennet @end|ng |rom um|ch@edu
Sun Jun 14 17:30:06 CEST 2020
Summary
I was getting errors from the configure script that it could not find
the proj library file when it is installed outside of /usr/local. A
one line change to configure.ac and rerunning autoreconf solves the
problem. This problem exists both in the tar ball supplied by CRAN
mirrors and in the version provided by
$ svn checkout svn://scm.r-forge.r-project.org/svnroot/rgdal/
. . . .
Checked out revision 1009.
I hope that sufficient detail is provided in what follows to understand
the environment, the error, and why the proposed fix works. There is
almost certainly a better way to resolve the issue, but the proposed one
does work. I hope it will isolate the problem sufficiently that a more
correct fix can be created.
Environment description
#------------------------------------------------------------------------
CentOS Linux release 7.7.1908 (Core)
3.10.0-1062.9.1.el7.x86_64
GCC 8.2.0 Compiled from source
R version 3.6.3 (2020-02-29) Compiled from source with gcc/8.2.0
#------------------------------------------------------------------------
06-11-2020 09:22 $ wget http://download.osgeo.org/geos/geos-3.8.1.tar.bz2
./configure --prefix=/sw/arcts/centos7/gcc_8_2_0/geos/3.8.1
#------------------------------------------------------------------------
06-11-2020 09:26 $ wget http://download.osgeo.org/gdal/CURRENT/gdal-3.1.0.tar.gz
./configure --prefix=/sw/arcts/centos7/gcc_8_2_0/gdal/3.1.0 \
--with-libtiff=$IMG_LIBS_HOME \
--with-libjpeg=$IMG_LIBS_HOME --with-gif=$IMG_LIBS_HOME \
--with-hdf4=$HDF4_ROOT --with-hdf5=$HDF5_ROOT \
--with-geos=$GEOS_HOME --with-proj=$PROJ_HOME
#------------------------------------------------------------------------
06-11-2020 19:44 $ wget https://download.osgeo.org/proj/proj-6.2.1.tar.gz
./configure --prefix=/sw/arcts/centos7/gcc_8_2_0/proj/6.2.1
# Into the build directory, and before running make ; make install, we
unzip -o /sw/src/arcts/proj/proj-datumgrid-1.8.zip -d data
#------------------------------------------------------------------------
All of the base libraries pass tests and are known to work properly.
All R libraries obtained from a mirror of CRAN.
The prerequisite libraries for rgdal were install with these commands
and were successful.
install.packages('tidyverse', "/sw/arcts/centos7/Rgeospatial/062020")
install.packages('sf', "/sw/arcts/centos7/Rgeospatial/062020")
install.packages('rgeos', "/sw/arcts/centos7/Rgeospatial/062020")
Rgdal installation
# First attempted this install.packages(rgdal) command, which has worked
# in past years with slightly different versions
# (comand line broken for legibility)
install.packages('rgdal',
configure.args=c("--with-proj-include=${PROJ_INCLUDE}",
"--with-proj-lib=${PROJ_LIB}",
"--with-proj-share=${PROJ_SHARE}")
)
That failed on the configure test of `proj_create_context` because it is
unable to find the library with this message from `configure`. See note
at the end of this message for the complete transcript of the first attempt
at installation.
>> /usr/bin/ld: cannot find -lproj
The rgdal installation reports that it can find proj, and it is usable. The
following excerpt from the transcript shows configure properly finding
the proj libraries from pkg-config, and that it knows the proper PROJ_LIBS.
configure: pkg-config proj exists, will use it
configure: PROJ version: 6.2.1
configure: proj CPP flags: -DPROJ_H_API
-I/sw/arcts/centos7/gcc_8_2_0/proj/6.2.1/include
configure: PROJ LIBS: -L/sw/arcts/centos7/gcc_8_2_0/proj/6.2.1/lib -lproj
checking PROJ header API:... yes
Somewhere between that test and compilation of the test code for
proj_context_create shown above, it clearly loses the needed
'-L/sw/arcts/centos7/gcc_8_2_0/proj/6.2.1/lib' portion of PROJ LIBS.
Debugging information
To debug this, I unpacked the .tar.gz of the R package and ran `configure`
by hand. I obtained the same result.
Looking in the config.log generated by `configure`, I find that the compile
command used was. This confirms that the library location if reported
finding is not being used on the compile command for this test.
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
Nonetheless, I confirmed that by extracting the test code and compiling it
by hand with the correct library flag provided, it compiles. I modified
the `configure` script to include the missing library specification, and
`configure` also then runs to completion. That confirms that the problem
really is the missing '-L/sw/arcts/centos7/gcc_8_2_0/proj/6.2.1/lib' portion
of PROJ LIBS.
I then tried to locate where in the configure.ac file the library was
being lost or not set for the test, but I was only able to determine that
by adding $PKG_LIBS to LIBS manually after the block where the proj-libs
are determined, configure would now run to completion; it did.
I then applied the patch and recreated the installation tar ball to be used
with install.packages().
The procedure for doing that is to unpack rgdal_1.5-10.tar.gz as distributed
by CRAN mirrors, change to the rgdal directory, apply this patch,
*** configure.ac.original 2020-06-14 10:44:31.999142923 -0400
--- configure.ac 2020-06-14 10:47:59.830661680 -0400
***************
*** 397,402 ****
--- 397,403 ----
fi # proj_config_ok
fi # proj_lib_path
+ LIBS="${PKG_LIBS} ${LIBS}"
AC_MSG_NOTICE([PROJ LIBS: ${PKG_LIBS}])
run autoreconf to regenerate the configure script, obtain new md5sums for
configure and configure.ac, patch the MD5 file, change to the directory
above, tar the rgdal directory that contains the patched files, and use
that to install rgdal with install.packages().
After installation of the patched version, I get this upon loading the rgdal
library.
> library(rgdal)
Loading required package: sp
rgdal: version: 1.5-10, (SVN revision 1006)
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 3.1.0, released 2020/05/03
Path to GDAL shared files: /sw/arcts/centos7/gcc_8_2_0/gdal/3.1.0/share/gdal
GDAL binary built with GEOS: FALSE
Loaded PROJ runtime: Rel. 6.2.1, November 1st, 2019, [PJ_VERSION: 621]
Path to PROJ shared files: /sw/arcts/centos7/gcc_8_2_0/proj/6.2.1/share/proj
Linking to sp version:1.4-2
To mute warnings of possible GDAL/OSR exportToProj4() degradation,
use options("rgdal_show_exportToProj4_warnings"="none") before loading rgdal.
#============================================================================
#
# Transcript of the first, failed installation attempt
#
#============================================================================
> 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...
/sw/arcts/centos7/gcc_8_2_0/gdal/3.1.0/bin/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
-I/sw/arcts/centos7/gcc_8_2_0/proj/6.2.1/include
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-sig-Geo
mailing list