makefile运行它编制的代码
makefile to run the code it compiles
如果我有一个可以运行的代码,将其称为 main.cpp
,并且可执行文件为 r.exe
,则用以下目标编写makefile:
compile:
g++ -std=c++11 main.cpp -o r
可执行文件,r.exe
作为两个参数i.txt
,o.txt
。我如何在makefile中添加第二个目标,以便可以运行以下命令,并查看程序执行:
make run i.txt o.txt
我尝试在makefile中添加第二个目标:
run:
r.exe $1 $2
例如,但要声明:"'r'是最新的"answers"为'i.txt',...等无需完成。"
我还尝试了一段时间,但是"制作","运行"answers"变量"或"参数"本质上具有无关内容的搜索防火墙。
您不能这样将参数传递给make
。命令make run i.txt o.txt
将尝试构建规则run
,i.txt
和o.txt
。
您可以使用一个变量:
run:
r.exe ${ARGS}
make run ARGS="i.txt o.txt"
旁注,规则应制作他们说的文件。因此,您确实希望您的编译规则看起来像:
r.exe : main.cpp
g++ -std=c++11 $^ -o $@
compile : r.exe
.PHONY : compile
相关文章:
- 我的代码运行良好,但在游戏循环中中断
- 通过窗口从C++代码运行 WSL 命令
- 如何使用 lldb 查找我的代码运行的位置
- 无法在 VS Code 上使用代码运行程序运行C++文件
- 我的代码运行良好,但现在当尝试将其制作成模板时,我遇到了许多看似无关的错误。这是怎么回事?
- Visual Studio代码运行环境
- 如何从C++代码运行自定义 GPU tensorflow::op?
- 在 ZeroMQ 中绑定订阅者套接字并连接发布者套接字会在代码运行时给出错误.为什么
- 代码运行缓慢
- .NET CORE 2 DLL引用带有C 代码运行时错误
- C++ 中控制台代码运行时的分段错误
- C++ 菜单代码 - 运行另一个类
- 以下代码运行后,如何在程序再次运行之前清除用户声明的变量 empName
- 当我使用此合并排序代码运行时,输出错误
- 有哪些优化技巧可以使我的代码运行得更快
- 使 C 代码能够作为C++代码运行
- 错误代码LNK1561阻止我的代码运行
- 如果我用代码块编译代码,为什么我的代码运行速度更快
- 更改Linux用户从C/C 代码运行时间
- 为什么这段代码运行这么慢