what is the difference between linking and loading in c language

后端 未结 7 1775
庸人自扰
庸人自扰 2021-02-04 06:15

Does linking and loading of the the dynamic libraries both happen at runtime? or is it that only loading of the library happens at run time?

7条回答
  •  故里飘歌
    2021-02-04 06:58

    There are two types of linking: static linking and dynamic linking.

    Static linking occurs at compilation time, hence it occurs prior to loading a program. With static linking the external symbols that are used by your program (e.g. function names) are resolved at compile time.

    Dynamic linking occurs at run time, so it occurs after or at the time of the loading of a program. With dynamic linking the symbols are resolved either at loading time, or at run time when the symbol is accessed (lazy binding). The latter is more common.

提交回复
热议问题