问题
Consider a scenario where there are two shared library of different version.Consider A.1.so linked to B.so and A.2.so linked to C.so. Now both B.so and C.so are linked to d.exe . When B.so wants to invoke function in A.1.so, it ends up calling function in A.2.so .Because of this , it gives us undefined behaviour.
Now I want my B.so invoke only A.1.so.I can only modify A.1.so and B.so , nothing else. Using dlopen()
is one of the option, but for using dlopen()
, I have to make heavy changes in B.so. There are many solutions given earlier in Stack Overflow, but nothing seems to work. Kindly note that I can make code changes in A.1.so and B.so only.
Is there any other solution to this problem other than dlopen()
. I have mentioned some of the links below.
- https://blog.habets.se/2012/05/Shared-libraries-diamond-problem.html
- https://code.woboq.org/qt5/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h.html
- https://www.mailerq.com/blog/good-reasons-to-use-dlopen
- Loading multiple shared libraries with different versions
- Program use two conflicting shared libraries
- C++ two libraries depend on same lib but different versions?
- Linking with multiple versions of a library
- C++ two libraries depend on same lib but different versions?
回答1:
can you wrap all code in A1.cpp
in namespace A1
and add a using namespace A1
to B.cpp
?
By A1.cpp
an B.cpp
I mean all the relevant translation units for A1.so
and B.so
.
来源:https://stackoverflow.com/questions/56947406/two-library-of-different-versions-in-an-application