开发者

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.

  1. 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.

  2. 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 :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜