[GRASS-dev] iostream: static library?

Glynn Clements glynn at gclements.plus.com
Thu Jun 12 14:14:07 PDT 2014


Markus Neteler wrote:

> is there a reason that iostream is compiled as static library? Due to
> the C++ modules depending on it?

It's because it consists of C++ code, so the existing rules for
generating shared libraries won't necessarily work for it.

On Linux, SHLIB_LD is typically "gcc -shared", whereas it may need to
be "g++ -shared" for libraries containing C++ code. On other
platforms, the situation may be more complex, particularly if the C
and C++ compilers don't have a common heritage.

Using a static library avoids such issues, as a static library is
merely an archive of the individual object files. Whether those object
files were generated from C or C++ (or even from Fortran, for that
matter) makes no difference to the construction of the library.

If we wanted to (reliably) support the creation of shared libraries
containing C++ code, we'd need to extend the SC_CONFIG_CFLAGS macro
and the build system to handle C++ as well as C, then test it on a
wide range of platforms (it's the less common ones which will cause
the problems; Linux, BSD, Windows and OSX all use a single toolchain
for both languages). And we'd need to handle the case where the
platform simply doesn't support using C++ in shared libraries.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list