There are 2 development teams developing C ++ applications for the same OS (Scientific Linux 6.5):
Team_A uses the provided OS compiler and libraries (GCC 4.4.7, GLIBC_2.12, GLIBCXX_3.4.13) to create their application in C ++ 98 and various shared libraries.
Team_B uses the new version of GCC (4.8.3), which was built from the source. This is a native compiler, it is associated with the libc OS and uses standard OS headers, but has its own version of stdC ++ (GLIBCXX_3.4.19). Team_B uses this compiler in C ++ 11 mode to create its own application ( AppB ) and deploys libstdC ++ and libgcc_s with it.
Team_A provides Team_B services as a shared library (.so, .hpp): LibA . The library API is a set of C ++ classes (declaration in the header, implementation in .so), and the methods take std :: string and other stdC ++ classes as arguments.
At this point, we come to the problem: AppB creates GLIBCXX_3.4.19 C ++ 11 style std :: any objects and passes them to LibA, which interprets them as GLIBCXX_3.4.13 C ++ 98 style objects, and this may not be compatible with the transition.
This is problem? Could this lead to a crash of the application? Are std :: any implementations compatible between versions (same memory layout)? What about C ++ 98 vs C ++ 11?
Some plot twists that bother me:
- AFAICT, when AppB runs only one downloadable libstdC ++ there, a new one. Even if LibA contacts older ones, it will not load.
- But the characters in libstdc ++ are versioned. So, if LibA explicitly uses an older version of the character, that will be associated with it. This means 2 different implementations of the same function will be used by AppB and LibA.
- std :: string and template classes containing templates, this means part of their implementation ends where it is generated, part of it in libstdC ++. So. Even if the new libstdC ++ is loaded, the generated template code in LibA is from the old version.
I would like to understand what exactly happens in this case, if it is risky and emptiness. Getting teams in one development environment is not an option. Removing std :: classes from the API will also be very difficult to do.
Any pointers are welcome! :)
c ++ gcc c ++ 11
Gyorgy szekely
source share