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?
我知道.OBJ是编译一个编译单元的结果,而.LIB是一个可以从几个.OBJ创建的静态库,但这种差异似乎只是在编译单元的数量上。还有其他区别吗?是相同还是不同的文件格式?
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?
我想知道在链接到最终可执行文件期间是否合并了两个(或更多).LIB中定义的相同静态变量。对于.OBJ,变量是合并的。但是在.LIBs中它是一样的吗?
2 个解决方案
#1
35
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.
.LIB文件是与索引连接在一起的.OBJ文件的集合。链接器处理方式应该没有区别。
#2
4
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.
似乎.lib文件就像.obj文件的集合。有些人还会考虑将多个.obj文件切换为.lib文件的过程,如Archive。在这种情况下,.lib文件是一个.obj文件框,链接器可以同等对待它。
#1
35
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.
.LIB文件是与索引连接在一起的.OBJ文件的集合。链接器处理方式应该没有区别。
#2
4
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.
似乎.lib文件就像.obj文件的集合。有些人还会考虑将多个.obj文件切换为.lib文件的过程,如Archive。在这种情况下,.lib文件是一个.obj文件框,链接器可以同等对待它。