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.
这篇关于静态库如何链接到依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:静态库如何链接到依赖项?


基础教程推荐
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 我有静态或动态 boost 库吗? 2021-01-01
- 常量变量在标题中不起作用 2021-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 这个宏可以转换成函数吗? 2022-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- C++结构和函数声明。为什么它不能编译? 2022-11-07