I have learned that you cannot use shared libraries compiled with different compilers together because their ABIs are usually incompatible. The exception is of course if you have a pure C interface, then it is possible. However, I did not find a clear statement about static libraries in this regard, hence this question.
My question is if static libraries have the same issue. If my shared library links against a static library from a different compiler, will it compile and work as expected at runtime? Or will it compile and behave badly? Or will it never compile?
There are several kinds of mismatches which could occur, including:
int can have different widths on different operating systems.std::string, std::map and other classes can be implemented differently by each library vendor, and since many people use the standard library provided by their compiler vendor, this issue may arise.Some of these, like name mangling, are likely to result in build failures. Others may seem to build OK but behave unexpectedly at runtime. Whether you're using static or dynamic linking, the overall situation is the same.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With