什么是C中的目标文件? [英] What's an object file in C?

查看:95
本文介绍了什么是C中的目标文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我阅读有关C库,但我还没有发现什么目标文件尚未作出解释​​。什么是其他任何编译的文件和目标文件的真正区别?会很高兴,如果有人能在人类语言解释。 :)

I am reading about libraries in C but I have not found yet an explanation on what an object file is. What's the real difference between any other compiled file and an object file? Would be glad if someone could explain in human language. :)

推荐答案

这是目标文件是由编译阶段的实际输出。这主要是机器code,但有信息,允许连接器,看看是什么符号,它还有象征它需要为了工作。 (仅供参考,符号基本上都是全局对象,函数等的名称)。

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆