Difference between *.lib and *.dll
-
wrote on 15 Mar 2013, 09:29 last edited by
Hello everyone,
Although, this may seem very trivial question I am thinking about it for a long time.
Qt comes with two sets of files lib files as in QtCore4.lib and dll files as in QtCore4.dll. I am little confused on the content of both. On the usage front I know, where it's being used, but can't figure out what exactly is happening?While, the libs files are added in Additional Dependencies in Visual Studio, I need to supply the dll files with my executable. Why do i need to supply the dlls along with the executable?
thanks
durgesh -
.lib files are using in linking, as the last stage of build process. DLLs are used by live applications.
-
wrote on 15 Mar 2013, 11:47 last edited by
.lib files are static libraries to be linked into your binary at compile time, dlls are dynamic libraries, linked at start-up time.
Usually when you have a library using dlls they also ship small stub-libs. Those lib files don't contain the actual functionality, they merely let you statically link to an interface that is compatible to the corresponding dll.
-
You can also think about it this way:
.dll contains the actual code. If you had only the .dll you would have to call LoadLibrary and GetProcAddress (on Windows, or the Qt equivalents from QLibrary) to actually call any function.
.lib contains the code that is statically linked into your executable to allow you to make the calls directly, without explicitly loading the dll. It does not contain the code of the functions.
-
wrote on 15 Mar 2013, 15:33 last edited by
Thanks everyone for prompt answers. :)
Can anybody point me to some tutorial to create and use dlls/lib to be used in another projects.
-
There are tons of articles about it. Just goolge shared library tutorial with your favourite IDE.
An example from "codeproject":http://www.codeproject.com/Articles/85391/Microsoft-Visual-C-Static-and-Dynamic-Libraries.
1/6