In the following webpage,
https://developer.android.com/ndk/guides/cpp-support
it states that having two libraries (libA.so, libB.so) compiled with c++_static
breaks the one-definition rule, in which multiple symbols will be defined for c++ functions in the different libraries. This case is then undefined behaviour, where multiple bugs could occur.
However, I don't know if this also happens for the following scenario:
libA.a
linked agsint c++_static
libB.so
and link against c++_static
and libA.a
In such case, the problem would not occur, and it would be safe to link the shared library against the static library, am I correct? Or are the symbols from libc++
embedded in libA.a
?
It is safe. In fact, neither libA.a
nor libB.a
will be linked against libc++
. Static libraries are not linked against their dependencies - this is done when linking executables/shared objects which use those libraries.
The only code from libc++
that will end up in those two static libs will be (inlined) code from headers. That's not a problem.