C中的目标文件是什么? [英] What's an object file in C?
问题描述
我正在阅读C中的库,但我还没有找到一个解释对象文件是什么。任何其他编译文件和目标文件之间的真正区别是什么?
如果有人可以用人类语言解释,我会很高兴。
I am reading about libraries in C but I have not yet found an explanation on what an object file is. What's the real difference between any other compiled file and an object file?
I would be glad if someone could explain in human language.
推荐答案
目标文件是编译阶段的真正输出。它主要是机器码,但有一个信息,允许链接器看到它里面的符号,以及为了工作需要的符号。 (参考,符号基本上是全局对象,函数等的名称)
An object file is the real output from the compilation phase. It's mostly machine code, but has info that allows a linker to see what symbols are in it as well as symbols it requires in order to work. (For reference, "symbols" are basically names of global objects, functions, etc.)
链接器获取所有这些对象文件并将它们组合成一个可执行文件它可以,即:没有任何重复或未定义的符号)。很多编译器会为你这样做(读:它们自己运行链接器)如果你不告诉他们只是编译使用命令行选项。 ( -c
是一个常见的只是编译;不链接选项。)
A linker takes all these object files and combines them to form one executable (assuming that it can, ie: that there aren't any duplicate or undefined symbols). A lot of compilers will do this for you (read: they run the linker on their own) if you don't tell them to "just compile" using command-line options. (-c
is a common "just compile; don't link" option.)
这篇关于C中的目标文件是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!