Differences between static libraries and dynamic libraries ignoring how they are used by the linker/loader

前端 未结 3 1372
执笔经年
执笔经年 2021-02-11 01:41

I understand how static/dynamic libraries are used by the linker/loader.

  1. However why not have a single type of library file accompanied by compiler flags which in
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-11 02:24

    1. The format of dynamic libraries, loaded at run-time, is determined by the operating system writers. The format of static libraries is set by the tool chain writers. Often there is some overlap between those classes of programmers, but they tend to prefer maintaining separation of concerns.
    2. The run-time loader needs to know the size of the image to load, maybe some stack and data segment sizes and the names and entry points of the functions in the DLL. The linker needs to know a great deal more about each of the objects (functions/data) archived in a static library. Things like function signatures, data types, sizes of things, initialization, scope of access.

    Every OS and tool chain has it's own specific requirements and revision history, so it would not be practical to delineate exact file layouts for all of them here. Refer to the OS and tool chain documentation for details.

提交回复
热议问题