The difference between static lib files, dynamic lib files and dll files

This switched https://blog.csdn.net/woainishifu/article/details/53505866

  • Foreword

bin folder inside the dll files are placed;

Dynamic lib lib folder files are associated with which put dll file;

staticlib folder which put the real static lib files and dll files are independent; (in this way is now gradually being abandoned)

  • Static lib file

Static lib file is actually a collection of arbitrary obj files. If your project has a number of cpp files, it will generate lots of obj file after compiling, then the final link only generate a lib file. Therefore, the static lib file actually contains the export declaration and implementation of all functions. If you put this lib file links to their own procedures, all of the code in this lib file will be embedded in, even if you only use a part of it, the rest is useless to also enter your code. Although convenient, but necessary to publish a new application if you are less than most, it will naturally lead to your library does not make sense to volume increases, losing the flexibility of using shared libraries, and released a new version of the job rather than simply a patch just fine. It is because of this shortcoming, it will appear this way dynamic dll call.

  • Dynamic lib files and dll file

It put these two together, because a dll project to generate a dll file, always accompanied generate a lib file, the file is actually a lib lib dynamic, its size is much smaller than the static lib because the lib file is really just a function of the index contains some information recorded in the dll entrance and location of those functions, it is the concrete realization of the dll function.

So why have dll, but also have a lib it? This is a process of dynamic link library

(1) compilation: This procedure only need to use this dynamic lib file [Note: In the case of a static lib, lib file is still only used at compile time, but static lib file contains a complete implementation, so the compiler generates exe then you can directly use it], and your code then packaged together.

(2) Run: This process will need to use the dll files, packaged good things on top of it, just recorded the entry and use of the specific location of those functions, and there is no real implementation code, so during running, those found by the entrance in the correct position dll is located, and then execute those functions directly on the line.

From the above process we can also see a very clear fact: DLL is actually exe, but it is not the main function, so it can not perform alone . In fact, in actual use, we also found that many applications are not a complete single executable file, which is divided into a number of separate relatively contradictory dynamic link library, and only when the execution of the application, with to the dll it will be called. This is why you often open certain programs because "could not be loaded XXX.dll" will appear.
 

Guess you like

Origin blog.csdn.net/jgj123321/article/details/94621172
Recommended