Qt5.x解决报错main.cpp:1:10: fatal error: QApplication: No such file or directory问题
Qt5.x解决报错main.cpp:1:10: fatal error: QApplication: No such file or directory问题
- 问题描述
- 定位问题
- 解决方法
- The end
问题描述
创建Qt5项目完成后,编译出现如下错误:
$ qmake -project
$ ls
Image.pro main.cpp
$ qmake -makefile
$ make
g++ -c -pipe -O2 -Wall -Wextra -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I. -I. -I../../../Qt/5.15.0/gcc_64/include -I../../../Qt/5.15.0/gcc_64/include/QtGui -I../../../Qt/5.15.0/gcc_64/include/QtCore -I. -isystem /usr/include/libdrm -I../../../Qt/5.15.0/gcc_64/mkspecs/linux-g++ -o main.o main.cpp
main.cpp:1:10: fatal error: QApplication: No such file or directory#include <QApplication>^~~~~~~~~~~~~~
compilation terminated.
Makefile:748: recipe for target 'main.o' failed
make: *** [main.o] Error 1
定位问题
此错误是由于从Qt版本5开始,所有native GUI功能都已从core模块移至单独的模块,即widgets
模块。应该向qmake声明应用程序依赖于该模块。
解决方法
修改项目文件.pro文件,例如创建Image项目,则为Image.pro。
$ vim Image.pro
添加greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
修改完成后Image.pro如下(不考虑注释行):
TEMPLATE = app
TARGET = ImageViewer
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
INCLUDEPATH += .
SOURCES += main.cpp
再次编译项目即可。
$ qmake -makefile
$ make
$ ls
Image Image.pro main.cpp main.o Makefile
$ ./Image
简单测试,成功执行:
The end
Enjoy coding.
Qt5.x解决报错main.cpp:1:10: fatal error: QApplication: No such file or directory问题相关推荐
- 【Qt】main.cpp:1:24: fatal error: QApplication: No such file or directory
QT版本:5.7.0 代码: #include <QApplication> #include <QLineEdit> #include <QPushButton> ...
- 解决编译redis报错zmalloc.h:50:10: fatal error: jemalloc/jemalloc.h: No such file or directory
解决方法 进入redis的目录后运行: sudo make 时报错:zmalloc.h:50:10: fatal error: jemalloc/jemalloc.h: No such file or ...
- edk2编译报错 BrotliCompress.c:20:10: fatal error: ./brotli/c/common/constants.h: No such file or directo
近期github上的edk2版本有些问题 edk2\BaseTools\Source\C\BrotliCompress\brotli edk2\MdeModulePkg\Library\BrotliC ...
- CentOS中输入yum报错:sudo: unable to execute /bin/yum: No such file or directory
今天尝试更新了下虚拟机CentOS中的python版本后. 运行"yum"命令,就报错:"sudo: unable to execute /bin/yum: No suc ...
- import dlib,报错:ImportError: libcublas.so.10.0: cannot open shared object file: No such file or direc
import dlib,报错:ImportError: libcublas.so.10.0: cannot open shared object file: No such file or direc ...
- python保存与加载LGBM模型,并解决报错TypeError: Need at least one training dataset or model file or model string..
方法一(适用于sklearn接口:from lightgbm import LGBMClassifier) 比如现在有一个lgbm_model import joblib# 保存 joblib.dum ...
- 关于nginx报错/usr/share/nginx/html/jiankongshare failed (2: No such file or directory)的问题解决...
nginx的location虚拟目录配置: monitor.conf server { server_name monitor.chinasoft.com; server_ ...
- Autopep8 安装时出现的两种报错 failed to create process 和 [Errno 2] No such file or directory
Autopep8 安装时出现的两种报错 1.failed to create process 2.[Errno 2] No such file or directory 小结 关键词: autopep ...
- vscode——运行程序报错 cc1plus.exe: fatal error: xxx: No such file or directory
问题描述 当我点击运行我编写的 c.cpp文件时,产生了如下错误:cc1plus.exe: fatal error: Vscode\c.cpp: No such file or directory 我 ...
最新文章
- 如何零基础学习python语言_零基础如何入门Python语言?有哪些学习建议?
- 如何判断轮廓是否为圆?
- 遭遇错误:ORA-01031
- 大中型企业的天网:Apache Geode
- 找不到或无法加载主类 org.jivesoftware.openfire.starter.ServerStarter
- vue-router 传递参数的几种方式
- 他走了,留下了3800亿元的帝国
- 删除链表倒数第N个节点
- 验证注册页面信息(JavaScript)
- 没想到!2018微信年度数据报告显示使用最多的表情竟是...
- 科学家量子计算机时间倒流,科学家用量子计算机让“时间倒流”?并没有真的做到...
- 数理知识(1):虚无假设、显著性检验、统计推断、P值法
- win10电脑wifi服务器未响应,Win10系统点击无线图标没反应的解决方法
- ★ Android 各类依赖库文件 收藏 ★
- 压缩图片大小至指定Kb以下
- 字符串根据字节长度进行截取并展示选中效果——js字符串获取字节长度
- Ubuntu USB设备端口号绑定
- 苹果抛弃 OpenGL !
- asterisk、pbx、sip等基本概念
- html5星际,纯原版复刻 牛人打造星际争霸HTML5版
热门文章
- (第8天) 什么是Mybatis缓存(Cache)
- 怎样把一个字典的数据添加到另一个字典中?
- 解除mysql只有本机可以访问的限制
- shell脚本中定义路径变量出现的BUG
- transform:rotate在手机上显示有锯齿的解决方案
- QT生成在Windows下有图标的exe文件(IDE=QT Creator)
- [转载] python中@property和property函数使用
- Quartus 与modelSim联合仿真常见错误以及系统任务$readmemb和$readmemh解释
- hidden field implements session
- Spark之Task原理分析