What is the difference between .LIB and .OBJ files? (Visual Studio C++)
Asked Answered
E

2

33

I know .OBJ is the result of compiling a unit of compilation and .LIB is a static library that can be created from several .OBJ, but this difference seems to be only in the number of units of compilation. Is there any other difference? Is it the same or different file format?

I have come to this question when wondering if the same static variable defined in two (or more) .LIBs is merged or not during linking into the final executable. For .OBJs the variables are merged. But is it the same in .LIBs?

Endogen answered 1/9, 2009 at 7:37 Comment(0)
B
46

A .LIB file is a collection of .OBJ files concatenated together with an index. There should be no difference in how the linker treats either.

Bipartite answered 1/9, 2009 at 7:38 Comment(0)
L
6

It seems like the .lib file is like a collection of .obj files. Some people also regard the process,that switch several .obj files to .lib files, as Archive. In that case, the .lib file is a box of .obj file, which could be treated equally by linker.

Lasley answered 26/8, 2010 at 15:27 Comment(1)
.lib in windows is same as .a in linux.Bulgar

© 2022 - 2024 — McMap. All rights reserved.