I have some C++ code in place, which internally uses multiple third party libraries. The code compiles fine but during execution it is failing to load some shared library(libintbasic.so). Given the condition, I can not install any library into the system, the only way out is to find which function is calling that library. How could I find that out who is calling that library (my code does not call that directly).
-
1Find the line which causes the call using a debugger. – eerorika May 27 '15 at 14:07
-
1You may want to add the "linux" tag – Paolo M May 27 '15 at 14:17
3 Answers
I can not install any library into the system,
That appears to be a bogus claim: clearly you can copy your binary onto the system. Installing an additional library into the same directory is not much harder.
How could I find that out who is calling that library
There are two cases to consider:
- your binary or one of the libraries it is directly linked with links to
libintbasic.so
. Your binary will not run at all, or - your binary, or one of the libraries it is directly linked with calls
dlopen("libintbasic.so",...)
and fails when thatdlopen
fails.
Debugging the first case is often easiest by setting LD_DEBUG=files,libs
. The dynamic loader will then tell you which libraries are being loaded, and why they are required.
Debugging the second case is easy with gdb
: set a breakpoint on dlopen
, and execute where
and info shared
commands every time the breakpoint is hit.

- 199,314
- 34
- 295
- 362
Remove the linking option -lintbasic, you will see all the functions that needs this library in the error messages. This is not clean but it should work fine.

- 808
- 1
- 8
- 17
-
Well, that's not really something which I wanted to do. I want to get rid of those functions which is calling that. I want to find out those functions. – ari May 27 '15 at 15:01
You may use ldd utility recursively for find all dependencies between shared libraries.
The following link also may be useful: Does ldd also show dependencies of dependencies?
-
2Welcome to Stack Overflow! Whilst this may theoretically answer the question, [it would be preferable](//meta.stackoverflow.com/q/8259) to include the essential parts of the answer here, and provide the link for reference. – Mat Oct 24 '18 at 08:53