简体   繁体   English

libc和crt1.o是静态链接还是动态链接?

[英]is `libc` and `crt1.o` statically or dynamically linked?

I'm really just trying to get my head around static and dynamic linking. 我真的只是想让我了解静态和动态链接。

When I invoke a compilation driver like unix> gcc myfile.c , crt1.o and libc.a (or libc.dylib ) are linked to produce the executable by ld . 当我调用诸如unix> gcc myfile.c类的编译驱动程序时, crt1.olibc.a (或libc.dylib )将通过ld链接以生成可执行文件。 I want to guess that crt.o is linked statically and the standard C lib is linked dynamically. 我想猜测crt.o是静态链接的,而标准C库是动态链接的。 Yes? 是?

Thanks for help. 感谢帮助。 I think I may need a new text on linking :S ` 我认为我可能需要有关链接:S`的新文本。

want to guess that crt.o is linked statically and the standard C lib is linked dynamically. 想猜测crt.o是静态链接的,而标准C lib是动态链接的。 Yes? 是?

No. 没有。

Not exactly. 不完全是。

crt0.o and its family ( bundle1.o , dylib1.o , etc.) are object files, not libraries, they are not linked at all. crt0.o及其家族( bundle1.odylib1.o等)是对象文件,而不是库,它们根本没有链接。 libc.a is a static library so when you link against it, it will be linked statically (ie the object files it contains will be essentially copied to your executable). libc.a是一个静态库,因此当您对其进行链接时,它将被静态链接(即,它包含的目标文件实际上将被复制到可执行文件中)。 Static libraries aren't, however, linked themselves either. 但是,静态库也不链接自身。 libc.dylib is a dynamically linked library - guess how it is linked when you use it (dynamically, of course, and in this case, the library itself is a linked, proper executable file). libc.dylib是一个动态链接的库-猜猜使用时如何链接(当然是动态的,在这种情况下,该库本身是链接的,适当的可执行文件)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM