I've compiled a minimal example of code using Qt, and noticed that linking to its .lib
files added a requirement for my compiled program to link to its corresponding .dll
file.
I want to create a .lib
myself for one of my other projects to use, but want to do so without having to also make a .dll
for it to have to link to.
From the answer to this question: Difference between static and shared libraries?
Static libraries are .a (or in Windows .lib) files. All the code relating to the library is in this file, and it is directly linked into the program at compile time. A program using a static library takes copies of the code that it uses from the static library and makes it part of the program. [Windows also has .lib files which are used to reference .dll files, but they act the same way as the first one].
Am I correct in understanding that there are two types of .lib
files:
- a type that copies the code in it into the compiled program (removing the need for a
.dll
link) - a type that adds references to a
.dll
file into the compiled program
If this observation is correct, how would one go about compiling a .lib
of one of these types?