This question already has an answer here:
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 library
libtest.soto our program, if we remove the
libtest.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 of
dlopen, 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?