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?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Typically, the
.objfiles refer to object files. This is a source file in its compiled form. For example, amain.cppandfoo.cppwould producemain.objandfoo.obj.It is then the linkers job to link them together, so that
main.objcan reach functions defined infoo.objand 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 (
.libin your case) is the collection of linked.objfiles. Once you are finished compiling, and want to use the library, you only need other programs to link with the.lib. The.objare what’s considered intermediate files, and are not needed after linking is completed.