[geos-devel] 3.10.0rc1 (static)
Roger Bivand
Roger.Bivand at nhh.no
Fri Oct 15 02:00:00 PDT 2021
R Windows and macOS binary packages use static builds only to ensure
completeness. With Autotools, this involved some jumping through hoops and
local hot patching of --static-clibs and --static-libs adding -lstdc++,
but has remained feasible, with incantations like (-fPIC needed
downstream to link the package shared object into the R language engine):
mkdir build-static
cd build-static
export CFLAGS=-fPIC
export CXXFLAGS=-fPIC
export CPPFLAGS=-fPIC
../configure --prefix=/home/rsb/static_old --enable-static=yes
-disable-shared
make
make install
I have tried to grasp what has gone completely wrong with Cmake. I never
succeeded in using Cmake before to create libgeos.a and libgeos_c.a to use
in building R packages, but this was not a problem, because Autotools
worked.
My current incantation is:
mkdir build-static
cd build-static
export CFLAGS=-fPIC
export CXXFLAGS=-fPIC
export CPPFLAGS=-fPIC
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF
-DCMAKE_INSTALL_PREFIX=/home/rsb/static -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
..
cmake --build .
cmake --build . --target install
The simplest test is to try to build static, and to attempt to compile the
a test from rgeos/configure.ac:
cat > geos_test.cc << _EOCONF
#include <geos_c.h>
#ifdef __cplusplus
extern "C" {
#endif
static void __errorHandler(const char *fmt, ...) {
return;
}
static void __warningHandler(const char *fmt, ...) {
return;
}
int main() {
GEOSContextHandle_t r = initGEOS_r((GEOSMessageHandler)
__warningHandler, (GEOSMessageHandler) __errorHandler);
finishGEOS_r(r);
}
#ifdef __cplusplus
}
#endif
_EOCONF
g++ `<static/bin>geos-config --cflags` -o geos_test geos_test.cc \
`<static/bin>geos-config --static-clibs`
for me giving this failure for Cmake static, but success for Autotools:
/usr/bin/ld: /home/rsb/static/lib64/libgeos.a(WKTWriter.cpp.o): in
function `geos::io::WKTWriter::writeNumber[abi:cxx11](double) const':
WKTWriter.cpp:(.text+0xe39): undefined reference to
`geos_d2sfixed_buffered_n'
collect2: error: ld returned 1 exit status
This on current Fedora 34; when I can work out how to get a viable Cmake
workflow, I can try to transfer it to Windows cross-compilation under MXE
and native macOS.
Any help very welcome.
Roger
--
Roger Bivand
Emeritus Professor
Department of Economics, Norwegian School of Economics,
Postboks 3490 Ytre Sandviken, 5045 Bergen, Norway.
e-mail: Roger.Bivand at nhh.no
https://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
More information about the geos-devel
mailing list