r-spatial / lwgeom

bindings to the liblwgeom library
https://r-spatial.github.io/lwgeom/
58 stars 23 forks source link

Need to confirm existence of GEOS 3.5.0 #50

Closed wehopkins closed 4 years ago

wehopkins commented 4 years ago

Install of lwgeom failed due to not having GEOSClipByRect defined.

Here is the prebuild check:

checking geos-config usability... yes configure: GEOS: 3.4.2 checking GEOS version >= 3.3.0... yes checking geos_c.h usability... yes

It is missing from the headers that it is expected to be in:

gcc -std=gnu99 -I"/opt/R/3.6.1/lib/R/include" -DNDEBUG -DACCEPT_USE_OF_DEPRECATED_PROJ_API_H -DACCEPT_USE_OF_DEPRECATED_PROJ_API_H -I/usr/include -DPOSTGIS_GEOS_VERSION=34 -I./liblwgeom -DHAVE_LIBGEOM_INTERNAL_H -I"/opt/R/3.6.1/lib/R/library/Rcpp/include" -I"/opt/R/3.6.1/lib/R/library/sf/include" -I/usr/local/include -fpic -g -O2 -c liblwgeom/lwgeom_geos.c -o liblwgeom/lwgeom_geos.o liblwgeom/lwgeom_geos.c: In function ‘lwgeom_clip_by_rect’: liblwgeom/lwgeom_geos.c:954:2: warning: implicit declaration of function ‘GEOSClipByRect’ [-Wimplicit-function-declaration] if (!(g3 = GEOSClipByRect(g1, x1, y1, x2, y2))) ^

So is GEOSVoronoiDiagram.

liblwgeom/lwgeom_geos.c: In function ‘lwgeom_voronoi_diagram’: liblwgeom/lwgeom_geos.c:1926:2: warning: implicit declaration of function ‘GEOSVoronoiDiagram’ [-Wimplicit-function-declaration] geos_result = GEOSVoronoiDiagram(geos_geom, geos_env, tolerance, output_edges); ^

And not only is the function not declared, it is not defined: ** testing if installed package can be loaded from temporary location Error: package or namespace load failed for ‘lwgeom’ in dyn.load(file, DLLpath = DLLpath, ...): unable to load shared object '/opt/R/3.6.1/lib/R/library/00LOCK-lwgeom/00new/lwgeom/libs/lwgeom.so': /opt/R/3.6.1/lib/R/library/00LOCK-lwgeom/00new/lwgeom/libs/lwgeom.so: undefined symbol: GEOSClipByRect Error: loading failed

From what I can find, the function first appears in GEOS 3.5.0, so the prebuild check needs to verify the existence of 3.5.0 or newer, not 3.3.0.

dbaston commented 4 years ago

PostGIS started requiring GEOS > 3.5 a while back, so these ifdefs on these functions were removed from the lwgeom source. It doesn't seem unreasonable for this package to require GEOS >= 3.5 (released in 2015). Alternatively, could just remove parts of lwgeom that are never exposed to R from the tree in this repo.

wehopkins commented 4 years ago

Thanks! This is not a big deal, but the GEOS version is already being checked and it seems a simple fix to make it clear what is needed. Or, if that code isn’t needed for the R API, removing it is even better (reducing dependencies).

HenrikBengtsson commented 4 years ago

I'm on CentOS 7 which only comes with GEOS 3.4.2;

ldconfig -p | grep geos
        libgeos_c.so.1 (libc6,x86-64) => /lib64/libgeos_c.so.1
        libgeos_c.so (libc6,x86-64) => /lib64/libgeos_c.so
        libgeos-3.4.2.so (libc6,x86-64) => /lib64/libgeos-3.4.2.so

and when installing lwgeom 0.2.1 from CRAN, I get the same error as OP.

I just wanted you to be aware that requiring GEOS (>= 3.5.0) will cause troubles for people on RHEL/CentOS, which is quite common on academic HPC environments. (myself, I'll next in install a newer version of GEOS from source)

edzer commented 4 years ago

We now require GEOS >= 3.6.0, as PostGIS 3.0.0 does, from which we copy liblwgeom.