dependency of static library

Posted sunny,lee

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了dependency of static library相关的知识,希望对你有一定的参考价值。

一直以来都有一个误区,认为静态库就一定是不含任何依赖的,动态库是含的。这个印象是因为在我们程序中,包含静态库的地方,往往Build好之后直接就可以用,而含DLL的地方,则需要在build好之后的EXE中再加DLL。

那么前几天,遇到了一个问题,程序包含了A.lib之后,发现link fail. How could that be? we found that A.lib dependent on B.lib.(just trough the function name, I wonder if there is any other method)

So, the question is how could A.lib dependent on B.lib? Why B.lib is not included in A.lib?

事实很简单,静态链接库就是一个编译好的目标文件的集合,他并没有链接过,所以他不是最终的.out文件。跟可执行文件不一样。所以,这个依赖关系是可能的。当然我可以产生一个另一版本的A,可以将B完全包含在内。但是一般的A就是我们所编写的代码的和,如果有外部的LIB,就不包在里面了。VS中看有没有地方选??

 

所以,下一次就知道了,DLL和LIB都有可能有外部依赖。因为他们只是编译之后没有链接的半成品。

以上是关于dependency of static library的主要内容,如果未能解决你的问题,请参考以下文章

Understanding Inversion of Control, Dependency Injection and Service Locator Print

dpkg: dependency problems prevent configuration of python-gi

Inversion of Control Containers and the Dependency Injection pattern (Martin Fowler)

[C++ Weekly] EP2 Cost of Using Statics

[C++ Weekly] EP2 Cost of Using Statics

Tip of the Week #49: Argument-Dependent Lookup