I was told that the dynamic library is good because it can save RAM, it's only needed while the program is running.
Now I have a question: if a program can be executed, can I say that all of dynamic libraries that it needs have been there (there wouldn't be any dymanic librariy missing error)?
Saything that a program comes from a link of three .o
files, and each .o
file needs a dymanic library. If I remove one dynamic library, can I still make the program run?
As I know, we have two ways to load a dynamic library:
- Load a dynamic library when we link object files, for example,
g++ a.cpp -ltest
, here we link the dynamic librarylibtest.so
to our program, if we remove thelibtest.so
, we would not be able to execute the program. - Load a dynamic library with the system api function:
dlopen
. In this case, as my understanding, if the execution of the program doesn't touch the code ofdlopen
, we would not have any error.
If I'm correct, could I say if the execution of the program has no error, it means all of dynamic libraries it needs are definitely there?
s/the execution/an execution/
- you cannot conclude that from a single execution for the reasons already given in Stephen Kitt's answer. – muru Apr 17 '18 at 06:04