链接器和 makefile 有什么区别?
链接器接收 obj 和 lib 来创建 exe 或其他库。但是 makefile 也是如此(但它可以从其之上的源开始)。两者有什么区别?
a linker receives obj's and lib's to create exe's or other libs. But so does a makefile(but it can start from sources on top of that). what is the difference between the two?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
不,Makefile 没有。
Makefile 本质上是一个脚本,用于告诉 make 程序将哪些文件作为构建文件的一部分发送到哪些程序。
因此,Makefile 可以使用适当的源文件/目标文件调用编译器、链接器等,但它本身并不实际完成工作。
我认为您已经错过了 Makefile 的整个概念,所以我建议您做一些进一步阅读。
No, a Makefile does not.
A Makefile is essentially a script to tell the make program what files to send to what programs as part of the build file.
So, a Makefile can invoke the compiler, linker, etc with the appropriate source files/object files, but it doesn't actually do the work itself.
I think you have missed the whole concept of a Makefile, so I suggest you do some further reading.
链接器和 makefile 几乎没有任何共同点。 makefile 是
make
使用的一组指令。它们可以是构建程序、安装一些文件或您想要 make 执行的任何操作的指令。链接器是一种将目标文件作为输入并将它们组合成输出可执行文件(或共享库)的程序。A linker and a makefile have almost nothing in common. A makefile is a set of instructions used by
make
. They can be instructions that build a program, install some files, or whatever you wantmake
to do. A linker is a program that takes object files as input and combines them into an output executable (or shared library).makefile 只是某种规则集,它定义了需要编译的内容以及依赖于哪个编译过程关于什么。这样,制作软件就可以自动化该过程。
然而,使用 make 和 makefile 并不意味着您没有使用常规编译器和链接器。所以基本上那些仍然会运行,你只是不需要自己运行它,而是在 makefile 中定义之前的过程。
A makefile is just some kind of ruleset that defines what needs to be compiled and which compiling process depends on what. That way the make software can automate the process.
Using make and makefiles however does not mean that you are not using a regular compiler and linker. So basically those will still run, you just don't need to run it yourself, but define the process before in the makefile.
Make 使用 makefile 来评估一组规则,以确定是否在源文件上调用编译器(很可能是由于源文件发生变化),并最终调用链接器来创建最终目标文件。
您可以在这里阅读有关 make 的更多信息: http://www.gnu.org/software/make/< /a>
Make uses a makefile to evaluate a set of rules on whether to invoke the compiler on a source file (due to it changing, most likely) and eventually invoke the linker to create final object file.
You can read more about make here: http://www.gnu.org/software/make/