Reputation: 955
I'm a little confused as to why a 3rd party .dll I'm using comes with a .lib file labeled as an "import library." When I run the program, I just place the .dll in the same directory as the executable and it works. I'm using MinGW.
Could someone explain why the .dll comes with a .lib import library if I don't even need it? How would I even use it and where should I put it if I did use it with MinGW?
I read up on it and it looks like the .lib file is not needed by MinGW (what I'm using) and is needed by MSVC. Why is this?
P.S. If I wanted to put a .dll in a directory other than the directory containing the executable, could I put a line in the .pro file to point to it?
Upvotes: 1
Views: 652
Reputation: 36036
According to http://www.mingw.org/wiki/sampleDLL, MinGW can guess the information that's contained in a .lib
(DLL name, exported entries' names and ABI) from the corresponding .h
file and the DLL itself.
According to http://www.mingw.org/wiki/CreateImportLibraries, this works "for all DLLs created with MinGW and also a few others".
In cases when it can't guess correctly, you still need to provide a .lib
file. The latter link has instructions on how to generate one by hand if you haven't got a pristine one.
The former link refers to ld
docs for a more in-depth description. Specifically, it's at the ld and WIN32 (cygwin/mingw) node, "direct linking to a dll" section. Among other things, it outlines cases when a .lib
is necessary:
.lib
contains pure static objects (e.g. cygwinX.dll
)Upvotes: 3