为C ++程序创建Makefile和构建文件

时间:2018-10-15 19:12:48

标签: makefile

我是Linux的新手,我已经阅读了许多有关如何制作makefile的教程,但无法创建它。我试图编写一个makefile来创建一个新文件,将新文件format.cpp的内容复制到新文件中,并在sublime中启动该文件。 例如,如果我键入make hello.cpp,则它将创建一个新文件hello.cpp,并将format.cpp的内容复制到此hello.cpp中,并在sublime中启动该文件

第二,我试图编写一个build文件来编译并运行该c ++文件。 例如,目前我正在编译并运行我的c ++文件

g++ -o hello hello.cpp
./hello < input.txt > output.txt`

请帮助!!!

makefile的代码是:

src?=a.cpp

new: rm -f *.o *.out* cp format.cpp a.cpp subl a.in a.cpp

构建代码为:

in: $(src)
g++ -std=c++14 -fmax-errors=1 -DLOCAL -O3 $(src) -o a.out
./a.out < input.txt > output.txt
subl output.txt

如果我们不输入任何文件名,则默认情况下它将打开a.cpp

0 个答案:

没有答案
相关问题