Makefile简单例子


一个Makefile测试用例

Make 命令教程 -阮一峰|
Makefile 使用总结
Makefile学习笔记(一):Windows平台
关于windows下的makefile学习| 代码|


Windows下通过命令行编译C/C++程序

参考
helloword.cpp,run.bat代码
helloword.cpp文件

#include <iostream>
#include <stdio.h>

int main()
{
    std::cout << "This is a native C++ program." << std::endl;
    printf("printf: Hello World");
	system("pause");
    return 0;
}

run.bat文件(路径皆为自己电脑相应文件的路径,相应文件应区分32bit和64bit)

set include=E:\vs\VC\Tools\MSVC\14.16.27023\include;^
E:\Windows Kits\10\Include\10.0.10240.0\ucrt
set lib=E:\vs\VC\Tools\MSVC\14.16.27023\lib\x86;^
E:\Windows Kits\10\Lib\10.0.10240.0\ucrt\x86;^
E:\Windows Kits\10\Lib\10.0.10240.0\um\x86
cl helloworld.cpp
pause

运行run.bat前
在这里插入图片描述
双击run.bat后生成helloworld.exe,直接双击.exe即可运行)
在这里插入图片描述


Windows下通过命令行编译Qt程序

qmake用户手册
在命令行提示符窗口中编译运行qt程序|
从C++到Qt(命令行编译,讲解原理)|
helloword.cpp

#include <QApplication>
#include<QLabel>

int main(int argc,char **argv)
{
	QApplication app(argc,argv);
	QLabel label("hello world");
	label.show();
	return app.exec();
}

命令行

qmake -project
qmake
mingw32-make

报错:Missing Separator Error in Makefile
原因:look here
默认编译器问题,查看Makefile.Release中的这一个位置,在这里插入图片描述
解:从这儿启动,不要直接使用cmd窗口
在这里插入图片描述

报错: fatal error: QApplication: No such file or directory #include <QApplication>
原因:
解:.pro文件中添加 QT+=widgets

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值