I have a question about using libraries on Linux. Lets say I have a program called MYPROG and two libraries LIBABC.SO and LIBXYZ.SO. MYPROG loads the module LIBABC.SO with "dlopen RTLD_NOW". "dlopen" fails because I am using functions of LIBXYZ.SO and MYPROG was not linked with LIBXYZ.SO. Can I link a shared library to another shared library?
2 Answers
I believe so.
The main importance is that all functions you use in your applications are defined. If the definitions of those functions (the functions that are in, let's say, library A and not in your application) refer to library B, then it's library A's responsibility to link to library B.
Found the answer:
gcc -fpic obj1.c gcc -fpic obj2.o gcc -shared -o libABC.so -lXYZ obj1.o obj2.o