MobilityDB icon indicating copy to clipboard operation
MobilityDB copied to clipboard

Issue detecting GEOS >= 3.10

Open robe2 opened this issue 3 years ago • 6 comments

Describe the bug I'm trying to build Mobilitydb against PostGIS 3.3.0dev and GEOS (I've tried GEOS 3.11 dev and GEOS 3.10.1 and run into the same issue). However GEOS 3.9.1 it properly detects

To Reproduce Cmake against GEOS 3.10.1, I get

-- Building MobilityDB
-- POSTGRESQL_VERSION_MAJOR=11
-- POSTGRESQL_VERSION_MINOR=2
-- POSTGRESQL_BIN_DIR: C:/MING64~1/projects/POSTGR~1/rel/PG11W6~1/bin
-- POSTGRESQL_INCLUDE_DIR: C:/MING64~1/projects/POSTGR~1/rel/PG11W6~1/include/server
-- POSTGRESQL_LIBRARIES: C:/MING64~1/projects/POSTGR~1/rel/PG11W6~1/lib
-- POSTGRESQL_SHARE_DIR: C:/MING64~1/projects/POSTGR~1/rel/PG11W6~1/share
-- POSTGRESQL_DYNLIB_DIR: C:/MING64~1/projects/POSTGR~1/rel/PG11W6~1/lib
-- POSTGRESQL_VERSION: 11.2
-- POSTGRESQL_VERSION_NUMBER: 110200
-- POSTGRESQL_VERSION_STRING: PostgreSQL 11.2
-- POSTGIS_PGSQL_VERSION: 110
-- Several PostGIS versions found: Selecting C:/MING64~1/projects/POSTGR~1/rel/PG11W6~1/lib/postgis-2.4.dll
-- POSTGIS_LIBRARY: C:/MING64~1/projects/POSTGR~1/rel/PG11W6~1/lib/postgis-2.4.dll
-- POSTGIS_CONTROL: C:/ming64gcc81/projects/postgresql/rel/pg11w64gcc81/share/extension/postgis.control
-- POSTGIS_VERSION: 3.3.0
-- POSTGIS_VERSION_STR: PostGIS 3.3.0
-- LITTLE_ENDIAN
-- Found GEOS: C:/ming64gcc81/projects/geos/rel-3.10.1w64gcc81/lib/libgeos_c.dll.a ()
-- GEOS_INCLUDE_DIR: C:/ming64gcc81/projects/geos/rel-3.10.1w64gcc81/include
-- GEOS_LIBRARY: C:/ming64gcc81/projects/geos/rel-3.10.1w64gcc81/lib/libgeos_c.dll.a
-- GEOS_VERSION:
-- GEOS_VERSION_MAJOR:
-- GEOS_VERSION_MINOR:
CMake Error at CMakeLists.txt:148 (math):
  math cannot parse the expression: " * 10 + ": syntax error, unexpected
  exp_TIMES (2).

Expected behavior

Building against GEOS 3.9.1 gives expected behavior. So I assume it's either an issue with the extra digits or change in GEOS configs.

This is the output I get with CMAKE against GEOS 3.9.1 and what I expect. I'm still fixing some other dependencies, so haven't output those

-- The C compiler identification is GNU 8.1.0
-- The CXX compiler identification is GNU 8.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/ming64gcc81/mingw64/bin/gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/ming64gcc81/mingw64/bin/g++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Building MobilityDB
-- Looking for ffsl
-- Looking for ffsl - not found
-- POSTGRESQL_VERSION_MAJOR=11
-- POSTGRESQL_VERSION_MINOR=2
-- POSTGRESQL_BIN_DIR: C:/MING64~1/projects/POSTGR~1/rel/PG11W6~1/bin
-- POSTGRESQL_INCLUDE_DIR: C:/MING64~1/projects/POSTGR~1/rel/PG11W6~1/include/server
-- POSTGRESQL_LIBRARIES: C:/MING64~1/projects/POSTGR~1/rel/PG11W6~1/lib
-- POSTGRESQL_SHARE_DIR: C:/MING64~1/projects/POSTGR~1/rel/PG11W6~1/share
-- POSTGRESQL_DYNLIB_DIR: C:/MING64~1/projects/POSTGR~1/rel/PG11W6~1/lib
-- POSTGRESQL_VERSION: 11.2
-- POSTGRESQL_VERSION_NUMBER: 110200
-- POSTGRESQL_VERSION_STRING: PostgreSQL 11.2
-- POSTGIS_PGSQL_VERSION: 110
-- Found POSTGRESQL: C:/MING64~1/projects/POSTGR~1/rel/PG11W6~1/bin (found suitable version "11.2", minimum required is "11")
-- Several PostGIS versions found: Selecting C:/MING64~1/projects/POSTGR~1/rel/PG11W6~1/lib/postgis-2.4.dll
-- Found POSTGIS: C:/MING64~1/projects/POSTGR~1/rel/PG11W6~1/lib/postgis-2.4.dll (found version "3.3.0")
-- POSTGIS_LIBRARY: C:/MING64~1/projects/POSTGR~1/rel/PG11W6~1/lib/postgis-2.4.dll
-- POSTGIS_CONTROL: C:/ming64gcc81/projects/postgresql/rel/pg11w64gcc81/share/extension/postgis.control
-- POSTGIS_VERSION: 3.3.0
-- POSTGIS_VERSION_STR: PostGIS 3.3.0
-- LITTLE_ENDIAN
-- Found GEOS: C:/ming64gcc81/projects/geos/rel-3.9.1w64gcc81/lib/libgeos_c.dll.a (3.9.1)
-- GEOS_INCLUDE_DIR: C:/ming64gcc81/projects/geos/rel-3.9.1w64gcc81/include
-- GEOS_LIBRARY: C:/ming64gcc81/projects/geos/rel-3.9.1w64gcc81/lib/libgeos_c.dll.a
-- GEOS_VERSION: 3.9.1
-- GEOS_VERSION_MAJOR: 3
-- GEOS_VERSION_MINOR: 9
-- POSTGIS_GEOS_VERSION: 39

robe2 avatar May 05 '22 03:05 robe2

Will have a look.

cvvergara avatar May 05 '22 17:05 cvvergara

I just tried building mobilitydb on Ubuntu ARM64 as detailed in #218, and though I have a 3.10 geos on it, it didn't complain about this issue. I was surprised, unless you've since fixed this. I'll have to check again. Might be a windows only issue or specific to a cmake version or only an issue if you have custom paths.

On the Ubuntu ARM64 I am running cmake version 3.22.1 on windows I'm running cmake version 3.23.1.

robe2 avatar May 22 '22 04:05 robe2

As @estebanzimanyi mentioned, I think this was a result of an unclean build dir because I ran into the same issue second time around on the same Ubuntu ARM64 when I forgot to clear out the build dir.

I've retested on my mingw64 where I was having the issue, and it doesn't happen if I start with a clean build directory.

As mentioned by @estebanzimanyi in email one possible solution would be for cmake to clear out the build dir. I'm going to close this since it wasn't the issue I thought it was.

robe2 avatar Jun 04 '22 18:06 robe2

Okay I think something else is going on. I thought

rm -rf build

Fixed the issue (but perhaps I was mistaken and I forgot to change my geos to 3.11). I tried again and still same issue. I confirmed I did remove that build folder

robe2 avatar Jun 04 '22 19:06 robe2

Dear Regina I have started working on this issue and the problem comes from the PostGIS function lwgeom_unaryunion_prec embedded in MobilityDB https://github.com/estebanzimanyi/MobilityDB/blob/develop/postgis/liblwgeom/lwgeom_geos.c#L788 I have verified and the code has not been changed in the latest version of PostGIS https://github.com/postgis/postgis/blob/master/liblwgeom/lwgeom_geos.c#L830 Building MobilityDB goes without problem. However, when I create the MobilityDB extension in psql I obtain the following error

# create extension mobilitydb cascade;
ERROR:  could not load library "/usr/local/pgsql/14/lib/libMobilityDB-1.1.so": /usr/local/pgsql/14/lib/libMobilityDB-1.1.so: undefined symbol: GEOSUnaryUnionPrec

Any idea how to solve this problem ?

estebanzimanyi avatar Jul 26 '22 08:07 estebanzimanyi

@estebanzimanyi That error suggests that either PostGIS or MobilityDb one is being compiled with GEOS > 3.9 and one is being compiled with GEOS < 3.9. Those functions are ifdefed out if PostGIS is compiled with a GEOS < 3.9

Oh forgot the other reason. You might have compiled them both against GEOS > 3.9, but your environment is picking up a GEOS perhaps a system installed GEOS < 3.9

robe2 avatar Sep 17 '22 23:09 robe2

Dear Regina

Now that the academic semester is finishing I finally had time to begin working on this issue.

I have problems making PostGIS work with GEOS 3.11 WITHOUT MobilityDB. I have installed from sources the latest versions of PostgreSQL, PostGIS and GEOS. I installed GEOS as stated in https://libgeos.org/usage/download/ I installed PostGIS and the output of .configure states

  PostGIS is now configured for x86_64-pc-linux-gnu

 -------------- Compiler Info -------------
  C compiler:           gcc -std=gnu99 -g -O0 -fno-math-errno -fno-signed-zeros -Wall
  C++ compiler (Wagyu): gcc -std=c++11 -x c++
  C++ compiler (FlatGeobuf): gcc -std=c++11 -x c++
  CPPFLAGS:              -I/usr/local/include   -I/usr/include/libxml2  -I/usr/include/json-c  -DNDEBUG
  LDFLAGS:               -lm
  SQL preprocessor:     /usr/bin/cpp -traditional-cpp -w -P
  Archiver:             gcc-ar rs

 -------------- Additional Info -------------
  Interrupt Tests:   DISABLED use: --with-interrupt-tests to enable

 -------------- Dependencies --------------
  GEOS config:          /usr/local/bin/geos-config
  GEOS version:         3.11.1
  PostgreSQL config:    /usr/local/pgsql/15/bin/pg_config
  PostgreSQL version:   PostgreSQL 15.1
  PROJ4 version:        63
  Libxml2 config:       /usr/bin/xml2-config
  Libxml2 version:      2.9.10
  JSON-C support:       yes
  protobuf support:     yes
  protobuf-c version:   1003003
  PCRE support:         Version 1
  Perl:                 /usr/bin/perl

 --------------- Extensions ---------------
  PostGIS Raster:                     disabled
  PostGIS Topology:                   disabled
  SFCGAL support:                     disabled
  Address Standardizer support:       enabled

 -------- Documentation Generation --------
  xsltproc:             /usr/bin/xsltproc
  xsl style sheets:     /usr/share/xml/docbook/stylesheet/docbook-xsl
  dblatex:              /usr/bin/dblatex
  convert:
  mathml2.dtd:          /usr/share/xml/schema/w3c/mathml/dtd/mathml2.dtd

Everything was built smoothly but I cannot load the PostGIS extension

$ psql test
psql (15.1)
Type "help" for help.

test=# select version();
                                               version
------------------------------------------------------------------------------------------------------
 PostgreSQL 15.1 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0, 64-bit
(1 row)

test=# create extension postgis;
2022-12-02 14:45:06.890 CET [26507] ERROR:  could not load library "/usr/local/pgsql/15/lib/postgis-3.so": libgeos.so.3.11.1: cannot open shared object file: No such file or directory
2022-12-02 14:45:06.890 CET [26507] STATEMENT:  create extension postgis;
ERROR:  could not load library "/usr/local/pgsql/15/lib/postgis-3.so": libgeos.so.3.11.1: cannot open shared object file: No such file or directory
test=#

Any idea why I am unable to load the PostGIS extension ?

Many thanks for your help

Esteban

estebanzimanyi avatar Dec 02 '22 13:12 estebanzimanyi

That error usually happens if you compiled PostGIS with a newer version than the geos you have installed in system.

Easiest fix is to recompile PostGIS against older GEOS, or if you don't need that old geos, remove it.

I suspect you must have GEOS installed somewhere in system.

apt search libgeos

should confirm that.

You could then try uninstalling it:

apt remove libgeos3.10.2

robe2 avatar Dec 12 '22 15:12 robe2

Dear Regina I was able to install GEOS 3.11.1 and everything works with the develop version of MobilityDB. The MacOS run on github https://github.com/estebanzimanyi/MobilityDB/actions/runs/3752956473 uses the latest version. Could you please verify whether you still have the problem ? Thanks !

estebanzimanyi avatar Dec 21 '22 22:12 estebanzimanyi

I am closing this issue since we have been working for some time with GEOS 3.11.1 without any problems.

estebanzimanyi avatar Feb 27 '23 07:02 estebanzimanyi