c ++的makefile格式是什么(What is the format of a makefile for c++)

编程入门 行业动态 更新时间:2024-10-13 14:25:34
c ++的makefile格式是什么(What is the format of a makefile for c++)

我之前使用过像

g++ myfile.cpp -o myoutput

编译我的c ++代码,但我想转而使用makefile。 所以我不知道天气我听起来是否愚蠢,makefile的简单格式是什么

就像我有一个名为template.cpp的cpp文件,如何使用make编译它?

I previously used commands like

g++ myfile.cpp -o myoutput

to compile my c++ code, but I wanna shift to make use of makefiles. So I don't know weather I sound Dumb or not, What is the simple format of a makefile

Like I have a cpp file named template.cpp, how do I compile it using make?

最满意答案

对于你提出的问题,最简单的makefile看起来像这样:

myfile: myfile.cpp g++ myfile.cpp -o myfile

请注意,这是第二行的硬标签。 如果你在一个名为makefile的文件中有这个,那么你可以从终端运行make来编译你的代码。

顺便说一下, 这是编写makefile的优秀教程 - 值得一读。

The simplest makefile, for what you asked, looks like this:

myfile: myfile.cpp g++ myfile.cpp -o myfile

Note that that's a hard tab on the second line. If you have this in a file called makefile then you can run make from the terminal to compile your code.

By the way, this is an excellent tutorial to writing makefiles -- well worth the read.

更多推荐

本文发布于:2023-08-05 20:31:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1437686.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:格式   makefile   format

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!