Reputation: 361
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?
Upvotes: 2
Views: 349
Reputation: 229058
Sure. If you run ldd
on existing libraries (e.g. in /usr/lib/), you'll see many of them are linked to other libraries, and unless instructed otherwise, a shared library will at least be linked to the C runtime library.
When you're creating libABC.so, link it to libXYX.so, as an example using gcc:
gcc -shared -o libABC.so -lXYZ obj1.o obj2.o
Upvotes: 3