Static and Dynamic linking in Visual studio

后端 未结 1 1903
借酒劲吻你
借酒劲吻你 2021-01-18 13:15

I understand the concept of Static and Dynamic linking. It is known that on Windows platform, .dll are the dynamic libraries and .lib are the stati

1条回答
  •  一整个雨季
    2021-01-18 13:44

    The "usual" windows tool chains offer two "flavours" of .lib.

    One is the static libraries you mention. When used, there is no associated .dll.

    The other is a stripped library that is only there to hook in the code to load and fix functions pointers for the dynamic library at load time.

    With dynamic libraries (the .dll) you can either load it your self (via. LoadLibrary) or you can use the stub (import) .lib you have been provided with the .dll. Favour the import .lib if one is provided.

    Why did I had to copy the .dll files when I already linked the static libraries (.lib) ?

    The .dll needs to be in the path, or the directory with the .exe for the loader to find it.


    How do I differentiate whether the .lib file is Static library or Dynamic library?

    Generally the documentation should include some level of detail about this. If they are lumped in the same folder, then I would assume the .lib is tied to the .dll. If all else fails, look at the file size; if the .lib is tied to the .dll, then it is normally small in comparison to the .dll.

    0 讨论(0)
提交回复
热议问题