What is the difference between static library and relocatable object file? Or between dynamic library and shared object file.
静态库和可重定位目标文件有什么区别?或者在动态库和共享对象文件之间。
And if it's not equal things, what have dynamic library, that allows to link with it, but shared object file doesn't?
如果它不相等的东西,什么有动态库,允许链接它,但共享对象文件不?
3 个解决方案
#1
7
A static library is basically just a collection of object files. It's typically just an ar
archive of object files. Using ar
, you can extract object files from the library, add different object files to it, etc.
静态库基本上只是一个目标文件的集合。它通常只是目标文件的ar存档。使用ar,您可以从库中提取目标文件,向其中添加不同的目标文件等。
Generally speaking, the difference between a dynamic library and a shared object file is the target -- Windows uses dynamic libraries, Linux uses shared objects. There is a little more difference than that, but not a whole lot.
一般来说,动态库和共享对象文件之间的区别是目标--Windows使用动态库,Linux使用共享对象。有一点不同,但不是很多。
#2
1
Dynamic (shared) libraries uses PIC code - the code will work regardless of the actual physical location of the library that is used by multiple executables in memory.
动态(共享)库使用PIC代码 - 无论内存中多个可执行文件使用的库的实际物理位置如何,代码都将起作用。
Static libraries are linked into the executable during the linking phased to create the executable.
静态库在链接阶段链接到可执行文件以创建可执行文件。
The advantage of dynamic libraries is the smaller footprint of the executable in memory. The advantage of static libraries is that you can just deliver the executable without the need to have the dynamic libraries and run a little faster and no effort is required to enable the library to exist anywhere in physical memory.
动态库的优点是可执行文件在内存中的占用空间较小。静态库的优点是,您只需交付可执行文件,而无需拥有动态库并且运行速度更快,并且无需任何操作即可使库存在于物理内存中的任何位置。
#3
0
Shard libraries save disk space if they are used by more than one executable. If multiple executable's that use the same function from a shared lib. are running each will get its own copy. Neither executable on disk will include that function's code but rather a reference to the shared lib.
如果多个可执行文件使用分片库,则它们会节省磁盘空间。如果多个可执行文件使用共享库中的相同函数。正在运行每个都会得到自己的副本。磁盘上的可执行文件都不包含该函数的代码,而是包含对共享库的引用。
#1
7
A static library is basically just a collection of object files. It's typically just an ar
archive of object files. Using ar
, you can extract object files from the library, add different object files to it, etc.
静态库基本上只是一个目标文件的集合。它通常只是目标文件的ar存档。使用ar,您可以从库中提取目标文件,向其中添加不同的目标文件等。
Generally speaking, the difference between a dynamic library and a shared object file is the target -- Windows uses dynamic libraries, Linux uses shared objects. There is a little more difference than that, but not a whole lot.
一般来说,动态库和共享对象文件之间的区别是目标--Windows使用动态库,Linux使用共享对象。有一点不同,但不是很多。
#2
1
Dynamic (shared) libraries uses PIC code - the code will work regardless of the actual physical location of the library that is used by multiple executables in memory.
动态(共享)库使用PIC代码 - 无论内存中多个可执行文件使用的库的实际物理位置如何,代码都将起作用。
Static libraries are linked into the executable during the linking phased to create the executable.
静态库在链接阶段链接到可执行文件以创建可执行文件。
The advantage of dynamic libraries is the smaller footprint of the executable in memory. The advantage of static libraries is that you can just deliver the executable without the need to have the dynamic libraries and run a little faster and no effort is required to enable the library to exist anywhere in physical memory.
动态库的优点是可执行文件在内存中的占用空间较小。静态库的优点是,您只需交付可执行文件,而无需拥有动态库并且运行速度更快,并且无需任何操作即可使库存在于物理内存中的任何位置。
#3
0
Shard libraries save disk space if they are used by more than one executable. If multiple executable's that use the same function from a shared lib. are running each will get its own copy. Neither executable on disk will include that function's code but rather a reference to the shared lib.
如果多个可执行文件使用分片库,则它们会节省磁盘空间。如果多个可执行文件使用共享库中的相同函数。正在运行每个都会得到自己的副本。磁盘上的可执行文件都不包含该函数的代码,而是包含对共享库的引用。