qgis/QGIS — pull request #1461 by rouault (2014-06-17 20:31:06+00:00)
Title: Use GEOS reentrant API (_r functions) and update requirement to GEOS >= 3.1.0

Currently QGIS uses the 'classic' GEOS API that uses a global context.
This can conflict with libraries that would also use the global context
and potentially finalize it whereas QGIS will still use it later.

See https://groups.google.com/forum/#!topic/spatialite-users/9YSU6c5AVQ4 for
such an example of such a recent issue with Spatialite.

The _r API is available since GEOS 3.1.0, which is already an ancient GEOS
version. For example, old-old-stable Ubuntu (Lucid 10.04) and Debian (squeeze)
ship with GEOS 3.1.0 or later.

Such move has also been done in GDAL 1.11
(http://lists.osgeo.org/pipermail/gdal-dev/2013-August/036877.html)
and MapServer 7.0 (https://github.com/mapserver/mapserver/issues/4733)

There's no easy way unfortunately to check at compile time that you don't
use the non _r API. I have patched my geos_c.h header to #ifdef that API (quite
painfull to do..). A postprocessing check can be done however with :

objdump -T output/lib/*.so | grep -v Base | grep GEOS | grep -v _r | grep -v "_ZN" | grep -v GEOSversion

It should return nothing.

To test the conditional branches on GEOS versions for advanced GEOS features, compile-tested by simulating GEOS 3.1.0 and GEOS 3.4.2