Dynamic and Static Libraries in C++

后端 未结 5 1835
甜味超标
甜味超标 2021-01-30 14:45

In my quest to learn C++, I have come across dynamic and static libraries.

I generally get the gist of them: compiled code to include into other programs.

Howeve

5条回答
  •  有刺的猬
    2021-01-30 15:14

    The difference between a static and dynamic library is that the linking is done at compile time for static libraries, embedding the executable code into your binary, while for dynamic libraries linking is done dynamically at program start. The advantages are that the libraris can be separately distributed, updated and the code (memory) can be shared among several programs.

    To use a library you simply provide -l to g++ for a lib.a or lib.so

提交回复
热议问题