我是否需要静态库静态链接?
在'C',Linux和
On 'C', Linux,
我是否需要静态库静态链接,或共享那些我有足够?
如果不是,为什么不呢? (难道他们不包含相同的数据?)
Do I need static libraries to statically link, or the shared ones I have suffice? If not, why not? (Don't they contain the same data?)
是的,你需要的静态库来构建一个静态链接的可执行文件。
Yes, you need static libraries to build a statically linked executable.
静态库的编译对象束。当你用静态的图书馆链接,它实际上是一样服用该库的编译结果,在当前项目拆包它们,使用它们,好像他们是自己的对象。
Static libraries are bundles of compiled objects. When you statically link with to library, it is effectively the same as taking the compilation results of that library, unpacking them in your current project, and using them as if they were your own objects.
动态库已经联系。这意味着,像搬迁的一些信息已经被固定起来,扔出去。
Dynamic libraries are already linked. This means that some information like relocations have already been fixed up and thrown out.
此外,动态库必须编译成与位置无关的code。这不是静态库的限制,并导致性能上的一些共同的平台上显著差异(如86)。
Additionally, dynamic libraries must be compiled as position-independent code. This is not a restriction on static libraries, and results in a significant difference in performance on some common platforms (like x86).
有存在如 ELF Statifier 的工具,试图捆绑动态链接库成动态链接的可执行文件,但它是非常困难的产生在所有情况下正常工作的结果。
There exist tools like ELF Statifier which attempt to bundle dynamically-linked libraries into a dynamically-linked executable, but it is very difficult to generate a correctly-working result in all circumstances.