如何使我的makefile覆盖一个文件


descript: progam.cpp
    g++ progam.cpp -o descript
    ./descript 2>output.txt | tee -a output.txt

根据我的理解,第一个命令编译program.cpp,第二个命令将输出发送到终端和一个文本文件。

是否有办法调整这个,使我:

  • 使用"制造"。通过程序提示。输出保存在Output .txt
  • 使用"。/description "或其他命令,用新的输出
  • 覆盖output.txt。

我对linux命令比较陌生,所以任何东西都会有所帮助。

Makefile中包含make clean函数可能会有所帮助。

示例make clean函数可以包括:

make clean:
    rm -f output.txt

然后,在Makefiledescript部分的开头插入make clean以自动删除先前的输出。

相关内容

最新更新