How do static libraries do linking to dependencies?(静态库如何链接到依赖项?)
问题描述
假设我有 libA.例如,它依赖于 libSomething,因为 libA 的非内联方法调用 libSomething.h 中的方法这一简单事实.在这种情况下,依赖关系如何联系起来?libA 在编译时是否必须静态链接到 libSomething,或者 libA 的用户(使用 libA 的应用程序)是否需要同时链接到 libA 和 libSomething?
Say I have libA. It depends on, for example, libSomething for the simple fact that a non-inline method of libA makes a call to a method in libSomething.h. How does the dependency link up in this case? Does libA have to statically link to libSomething when it is compiled, or will a user of libA (an application using libA) need to link to both libA and libSomething?
谢谢
推荐答案
静态链接只是将整个项目(函数、常量等)复制到生成的可执行文件中.如果静态库的代码包含对某些共享库项的引用,这些引用将成为生成的可执行文件中的依赖项.如果您链接库而不是可执行文件,则同样如此.
Static linking is just copying the whole items (functions, constants, etc) into the resulting executable. If a static library's code contains references to some shared library items, these references will become dependencies in the resulting executable. The same holds if you link a library instead of executable.
这个话题 讨论它在 Linux 中是如何发生的.
This thread discusses how it happens in Linux.
这篇关于静态库如何链接到依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:静态库如何链接到依赖项?


基础教程推荐
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 初始化列表*参数*评估顺序 2021-01-01
- CString 到 char* 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01