如何从 ac 目标文件生成可执行文件?
如何将目标文件制作为可执行文件?
How to make an object file to executable file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
如何将目标文件制作为可执行文件?
How to make an object file to executable file?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
您需要链接目标文件。您的命令:
将 file.c 编译为目标文件(通常称为
file.o
)。如果您去掉“-c
”,它将直接生成可执行文件:或者(如果您有多个文件并且不想在只有一个文件发生更改时编译所有文件,则更有用),分两步进行:
You need to link the object file. Your command:
compiles file.c into an object file (which would typically be called
file.o
). If you get rid of the '-c
', it will generate the executable directly:Alternatively (more useful if you have multiple files and don't want to compile all files when only one has changed), do it in two steps:
如果您的文件是包含
main
函数的.o
文件,您只需链接它即可,例如gcc file.o -oexecutable
If your file is a
.o
file that contains amain
function you just need to link it, for examplegcc file.o -o executable
使用ld命令。 “ld file.o -o 可执行文件。这将给出可执行文件。
Use the ld command. "ld file.o -o executable. This will give executable.