mardi 27 juillet 2021

How to avoid multiple copies of the code for std::vector

I've got one shared library -- let's call it the master. It produces one or more slave shared libraries. The slave shared libraries are interacting with the master via an interface, exchanging std::string, std::vector and others. The compile time of the slave shared libraries must be minimized as this compile is done at the customer site dynamically.

As long as the exchanged object is not a STL container, everything works fine. e.g.

  • master compiles NonStlObject.cpp and NonStlObject.h and produces global text symbols (T)
  • client uses NonStlObject.h and creates undefined global text symbols (U)

As soon as an STL container is being exchanged, I end up with 1 + numberOfSlaves copies of the STL code -- and matching compile time -- they are weak symbols (W) in both master and slaves.

Is there any way to avoid this, other than wrapping every STL container?

PS. I don't care to be informed, that the version of the compiler used for building the interacting shared libraries must be the same. Of course it must!

PPS. extern template seems to be ignored by the compiler when applied to std::vector

Aucun commentaire:

Enregistrer un commentaire