2

Similar situation to the post Linking two shared libraries with some of the same symbols, my program a.cpp is linked with two different 3rd-party dynamic libraries, say, lib1.so and lib2.so.

lib1.so contains function

foo();

lib2.so contains function

bar(); // it calls its own foo();
foo();

My compilation command is

g++ a.cpp lib1.so lib2.so

The reason I put lib1.so in front of lib2.so is that my a.cpp needs foo() in lib1.so and bar() in lib2.so. If we do nothing, bar() in lib2.so will call foo() in lib1.so when the program is running. If I change the order, my program will not be able to call foo() in lib1.so. If lib1.so and lib2.so were built by myself, I could use the solution in the mentioned post at the beginning of this question. However, I cannot control both libs and there are many APIs in both libs.

How can I specify the linking options for my program so lib2.so calls its own functions during runtime?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.