This is rarely a problem in practice.
There is nothing to worry about for the static functions and the built-in template functions defined in the header files: each compilation module gets its own copy (for example, in the .a library, there may already be many anonymous copies). This is normal because these definitions are not exported, so the linker does not need to worry about them.
For functions declared with non-static binding, whether your problem depends on how you link the .a library.
When you create a library, you usually will not be referenced in the C ++ standard library. The created library will contain undefined references to the standard C ++ library. They must be resolved before the final binary executable is created. This is usually done automatically when linking this final binary to the default (depending on the compiler).
There are times when people refer to a static library in the C ++ standard library. If you link several static libraries, each of which embeds a different library (for example, the standard C ++ library), then expect problems if there are any differences in these built-in libraries. Fortunately, this is a rare issue, at least with the gcc . This is a more common problem with Microsoft tools.
In some cases, a workaround is to create one or more conflicting static libraries in a dynamic library. Thus, each of these dynamic libraries can statically link its own copy of the problem library. As long as the dynamic library does not export characters from the problem library, and there is no incompatibility of the memory layout, there are generally no problems.
Mr Fooz
source share