我之前使用过像
g++ myfile.cpp -o myoutput编译我的c ++代码,但我想转而使用makefile。 所以我不知道天气我听起来是否愚蠢,makefile的简单格式是什么
就像我有一个名为template.cpp的cpp文件,如何使用make编译它?
I previously used commands like
g++ myfile.cpp -o myoutputto 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 myfileNote 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.
更多推荐
发布评论