链接对所有链接的是一个共同的静态库中的多个共享库 [英] Linking against multiple shared libraries that all linked against a common static library

查看:203
本文介绍了链接对所有链接的是一个共同的静态库中的多个共享库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设你有2共享库,lib1.so和lib2.so,在都具有libcommon.a静态链接到他们。将编译器抱怨不明确的符号参考,如果你是动态链接都lib1.so和lib2.so?或将编译器是足够聪明,知道libcommon符号LIB1和LIB2之间的共享,并允许你动态对阵双方联系呢?

Say you have 2 share libraries, lib1.so and lib2.so, that both have libcommon.a statically linked into them. Would the compiler complain about ambiguous symbol reference if you were to dynamically link both lib1.so and lib2.so? Or would be the compiler be smart enough to know libcommon symbols are shared between lib1 and lib2 and allow you to dynamically link against both?

推荐答案

静态库将用于内部解决的链接,但外部链接不会被传播到共享库接口,这样就不会有任何冲突。每个共享库将包括它自己的静态库code的副本。

The static library would be used to resolve the links internally but the external linkage would not be propagated to the shared library interface, so there would be no conflict. Each shared library would include its own copy of the static library code.

这篇关于链接对所有链接的是一个共同的静态库中的多个共享库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆