Two library of different versions in an application

青春壹個敷衍的年華 提交于 2019-12-05 05:08:57

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!