English 中文(简体)
相对于图书馆而言,静态联系实际上如何?
原标题:What does static linking against a library actually do?

Say I有一个名为libfoo的图书馆,其中包含一个类别、几个固定变量,可能有些与C链接,还有一些其他功能。

现在,我有一个主要方案来研究:

int main() {
   return 5+5;
}

当我汇编和链接时,我与<代码>libfoo链接。

这是否会有任何影响? 我的面积是否会明显增加? 如果是,为什么? 静态变量或其地址是否可并入我的可执行?

如果存在类似问题,或我特别 st。

最佳回答

它在现代连接器中胜过任何事情,因为它知道可以起诉的狗实际上使用平衡标志。 我的系统有4.4.1和2.20。

g++ linker_test.cpp -static -liberty -lm -lz -lXp -lXpm -o linker_test_unnecessary
g++ linker_test.cpp -static -o linker_test_none
ls -l linker_test_unnecessary linker_test_none 

他们都是626094人。 说明这一点也适用于动态连接,尽管两者的大小都很低。

问题回答

图书馆载有以前编纂的物体代码,基本上是一个固定图书馆,是一个档案库,档案有:o或obj文档。

联系人看着你的标书,看看看是否有任何未解决的名字,如果在图书馆看到这些名字,他们就会发现包括这些名字的标书,并重复。

因此,只有固定图书馆中需要的部分才列入你可执行的内容。

因此,就你而言,在你可以起诉的情况下,不会再添加任何东西。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签