isciences / exactextractr

R package for fast and accurate raster zonal statistics
https://isciences.gitlab.io/exactextractr/
274 stars 26 forks source link

installation on CentOS 7 "initGEOS_r not found in libgeos_c" #14

Closed cmarmstrong closed 4 years ago

cmarmstrong commented 4 years ago

I've attempted to install exactextractr but have had no luck. I'm on CentOS and have rebuilt most of the geospatial tools from Fedora, including GDAL-2.3.1-3 and geos-3.6.1-10, and installed these along with developmental libraries and headers. I've verified the locations of geos-config and libgeos_c, and that initGEOS_r exists in libgeos_c, but to no avail. I've also tried multiple versions and methods of installing geos, but each had the same result. Lastly, this same error can be found associated with rgeos and other R geospatial packages, but the solutions are varied (often involving installing an older rgeos) and none of these solutions have worked for me.

 * installing *source* package ‘exactextractr’ ...                                                                                                                                                                 
 ** package ‘exactextractr’ successfully unpacked and MD5 sums checked                                                                                                                                             
 ** using staged installation                                                                                                                                                                                      
 configure: exactextractr: 0.1.0                                                                                                                                                                                   
 checking for geos-config... /usr/bin/geos-config                                                                                                                                                                  
 checking geos-config usability... yes                                                                                                                                                                             
 configure: GEOS version: 3.6.1                                                                                                                                                                                    
 checking geos version at least 3.5.0... yes                                                                                                                                                                       
 checking compiling and building against geos_c... no                                                                                                                                                              
 checking geos: linking with -L/usr/lib64 -lgeos_c -lgeos -lm... no                                                                                                                                                
 ./configure: line 1854: -o: command not found                                                                                                                                                                     
 configure: Compilation and/or linkage problems.                                                                                                                                                                   
 configure: error: initGEOS_r not found in libgeos_c.                                                                                                                                                              
 ERROR: configuration failed for package ‘exactextractr'
nm -D /usr/lib64/libgeos_c.so | grep initGEOS

000000000000f190 T initGEOS
0000000000010cc0 T initGEOS_r

any help is appreciated! the raster package is simply too slow. FWIW I've successfully installed sf, sp, raster, rgdal, rgeos, gdalUtils, etc etc and every geospatial package save this one installs successfully, so it may be something with exactextractr's configure script (I saw recent updates attempting to resolve a problem with geos).

v/r, Chandler

dbaston commented 4 years ago

Hi Chandler,

Looks like the error is coming from line 1854, which is:

${CXX} ${CXXFLAGS} -o geos_test geos_test.cpp ${GEOS_STATIC_CLIBS} 2> errors.txt

The error message -o: command not found suggests that both the CXX and CXXFLAGS environment variables are undefined. CXX should be defined on line 1704 as the result of running R CMD config CXX14.

I tried installing R on a fresh CentOS 7.7 setup, and sure enough, R CMD config CXX14 returns nothing. I'm guessing this is because CentOS 7.7 ships with gcc 4.8.5 (from 2015), which can't compile C++14 (used by exactextractr).

The configure script should have better error message in this case (since it actually has nothing to do with GEOS), but I think you're going to have problems installing quite a few packages with a compiler this old. (I also wasn't able to install sf on this setup because the CentOS 7.7 GDAL is too old.)

cmarmstrong commented 4 years ago

thanks I'll see about updating the compilers, or perhaps switching to the new CentOS 8.

I recently switched from Anaconda's R and compilers to (re)building everything from source(rpms), hence I'm now using the old CentOS compilers instead of Anaconda. Given this it sounds like your diagnosis is on the right track, and is happening only now due to the switch from Anaconda.

cmarmstrong commented 4 years ago

to confirm: it was the C++14 compiler. Installing and enabling devtoolset-8 from the redhat software collections repo and recompiling R with gcc 8 fixed the issue. thanks!