Is it good to link a shared library against other shared libraries?
I have an application X which uses shared libraries A,B and C. Shared library C also uses some symbols from Shared library A. Application X is linked against A and B during compile time and it does dlopen开发者_StackOverflow to load C at run time.
My question is:
Is it a good idea to link C against A during link time or leave the symbol resolution for runtime?
Your option 1. But it does not work that way.
You link C with A.
As A is a dynamic lib this will do nothing phsically.
It verifies that all dependencies will be satisfied by A at runtime.At runtime when you dlopen() the shared lib C
It will open C and if you had not already linked against A it would also open A
But since A is already open it will just resolve symbols in C with the A that is open.
I would go with the option 2. Leave the resolution for runtime. Late binding is the best option. Also I never knew that option 1 was possible :)
精彩评论