How do .lib and .obj files relate to each other? What is their purpose? Is a .lib just a collection of .obj files? If so are the .obj's then stored inside the .lib making the .obj's unnecessary?
Typically, the .obj
files refer to object files. This is a source file in its compiled form. For example, a main.cpp
and foo.cpp
would produce main.obj
and foo.obj
.
It is then the linkers job to link them together, so that main.obj
can reach functions defined in foo.obj
and vice-versa. The linker will output your binary file, which is the .lib
(or .a
, or .exe
, or .dll``, etc).
So in a loose sense, yes, the binary output (.lib
in your case) is the collection of linked .obj
files. Once you are finished compiling, and want to use the library, you only need other programs to link with the .lib
. The .obj
are what's considered intermediate files, and are not needed after linking is completed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With