如何在使用Makefile构建后在cmd中运行该程序?
How to run the program in cmd after in builds with a Makefile?
我正在努力寻找一种方法,以便我的Makefile
在构建后cmd
执行构建的代码,我正在使用Sublime Text 3
并且我正在尝试构建一个带有外部标头的c++
文件。
这是我得到的(它显示了崇高文本"建筑结果"控制台中的初始菜单(:
function1 = Aleatori
main = main
language = g++
flags = -c
all: compile run
compile: main.o Aleatori.o #function2.o-
$(language) $(main).o $(function1).o -o $(function1).exe
main.o: $(main).cpp
$(language) $(flags) $(main).cpp
Aleatori.o: $(function1).cpp
$(language) $(flags) $(function1).cpp
.PHONY: clean
clean:
rm -f *.obj
.PHONY: run
run:
./$(function1)
如前所述,它只是输出程序的初始菜单,我无法与之交互。
g++ main.o Aleatori.o -o Aleatori.exe
./Aleatori
Benvingut al Brain Training Game! Si us plau, selecciona una dificultat:
1 - Facil
2 - Mig
3 - Dificil
感谢您的关注。 :)
终于让它工作了,以防有人对它感兴趣:
- 我删除了制作文件的"运行部分">
- 制作了一个自定义make.sublime_build,在 cmd 中调用"make"后运行程序。
- 不得不重新安装我的
mingw
并安装包含mingw
的msys2
make.sublime_build:
{
"cmd": ["make", "&&", "start", "cmd", "/c", "${file_path}/${file_base_name}.exe"],
"file_regex": "^(..[^:n]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${folder:${project_path:${file_path}}}",
"selector": "source.makefile",
"syntax": "Packages/Makefile/Make Output.sublime-syntax",
"keyfiles": ["Makefile", "makefile"],
"shell": true,
"variants":
[
{
"name": "Clean",
"shell_cmd": "make clean"
}
]
}
相关文章:
- 运行程序时出现问题
- 分段错误当我试图运行程序时出错
- C++ 每次运行程序时我都会"nan"输出的问题
- 通过 g++ 运行程序时没有这样的文件或目录
- 重新运行程序和字符串流?
- 无法在 VS Code 上使用代码运行程序运行C++文件
- 使用有限的 RAM 运行 c++ 程序
- 继续运行程序而无需任何干预,直到要求退出为止
- 如何在每次运行程序时写入文件的下一行?
- 控制台在运行C ++程序后立即关闭(无需调试)
- 运行程序时找不到共享对象库,但在编译过程中链接了它
- 远程运行程序
- 在 Heroku 上运行 C++ 程序
- 如何在Powershell中运行C++程序,就像CMD一样?
- 为什么与Java和Python相比,使用Cmake运行C++程序每次都需要这么长时间?
- C++随机数生成器通常在 Visual Studio 中运行程序时在 2 次后停止生成数字
- 崇高文本 3 - 在终端中编译并运行 C++ 程序(路径包含空格)
- 我收到阻止我运行程序的警告,但不确定如何解决
- C++ Visual Studio 无法完全运行程序
- 在SIGABRT c ++信号之后继续运行程序