Qt学习 踩坑总结1
- 在命令行里输入
qmake -projectqmake hello.promingw32-make
出现
D:/Software/Qt/Tools/mingw810_64/bin/mingw32-make -f Makefile.Release
mingw32-make[1]: Entering directory 'D:/Software/Qt/qt-book-examples/qt-book/chap01/hello'
Makefile.Release:64: *** missing separator. Stop.
mingw32-make[1]: Leaving directory 'D:/Software/Qt/qt-book-examples/qt-book/chap01/hello'
mingw32-make: *** [Makefile:37: release] Error 2
而使用qt creator编译运行没有问题,这三行命令是比较权威的书籍提供的,看起来也没有问题,那么究竟是什么问题呢?
我查了查这三行命令是怎么起作用的,发现它们是通过电脑设置的环境变量起作用,然而令我奇怪的是,qmake的地址是D:\Software\Qt\5.15.2\mingw81_64\bin,却没有在环境变量中找到,所以~一定有另一个qmake.exe在捣乱!我在"我的电脑"里查询qmake.exe,发现D:\ProgramData\Anaconda3\Library\bin也有一个qmake.exe,它就在环境变量中!
反正不经常用Anaconda3,我就删了这个环境变量替换成了正确的,果然解决了~然后出现了其他错误! :)
- 在命令行里输入
qmake -project
qmake hello.pro
mingw32-make
出现
D:/Software/Qt/Tools/mingw810_64/bin/mingw32-make -f Makefile.Release
mingw32-make[1]: Entering directory 'D:/Software/Qt/qt-book-examples/qt-book/chap01/hello'
g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -Wall -Wextra -Wextra -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I. -I. -I..\..\..\..\5.15.2\mingw81_64\include -I..\..\..\..\5.15.2\mingw81_64\include\QtGui -I..\..\..\..\5.15.2\mingw81_64\include\QtANGLE -I..\..\..\..\5.15.2\mingw81_64\include\QtCore -Irelease -I/include -I..\..\..\..\5.15.2\mingw81_64\mkspecs\win32-g++ -o release\hello.o hello.cpp
hello.cpp:1:10: fatal error: QApplication: No such file or directory#include <QApplication>^~~~~~~~~~~~~~
compilation terminated.
mingw32-make[1]: *** [Makefile.Release:123: release/hello.o] Error 1
mingw32-make[1]: Leaving directory 'D:/Software/Qt/qt-book-examples/qt-book/chap01/hello'
mingw32-make: *** [Makefile:45: release] Error 2
qt creator编译运行没有问题,于是对比命令行和qt creator生成的hello.pro文件,发现qt creator多了一行QT+=widgets,再次编译,输出如下,运行正常,release文件夹里的hello.exe可以运行!!!
D:/Software/Qt/Tools/mingw810_64/bin/mingw32-make -f Makefile.Release
mingw32-make[1]: Entering directory 'D:/Software/Qt/qt-book-examples/qt-book/chap01/hello'
g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -Wall -Wextra -Wextra -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I. -I. -I..\..\..\..\5.15.2\mingw81_64\include -I..\..\..\..\5.15.2\mingw81_64\include\QtWidgets -I..\..\..\..\5.15.2\mingw81_64\include\QtGui -I..\..\..\..\5.15.2\mingw81_64\include\QtANGLE -I..\..\..\..\5.15.2\mingw81_64\include\QtCore -Irelease -I/include -I..\..\..\..\5.15.2\mingw81_64\mkspecs\win32-g++ -o release\hello.o hello.cpp
g++ -Wl,-s -Wl,-subsystem,windows -mthreads -o release\hello.exe release/hello.o D:\Software\Qt\5.15.2\mingw81_64\lib\libQt5Widgets.a D:\Software\Qt\5.15.2\mingw81_64\lib\libQt5Gui.a D:\Software\Qt\5.15.2\mingw81_64\lib\libQt5Core.a -lmingw32 D:\Software\Qt\5.15.2\mingw81_64\lib\libqtmain.a -LC:\openssl\lib -LC:\Utils\my_sql\mysql-5.7.25-winx64\lib -LC:\Utils\postgresql\pgsql\lib -lshell32
mingw32-make[1]: Leaving directory 'D:/Software/Qt/qt-book-examples/qt-book/chap01/hello'
后话:
百度查qmake在windows命令行里的用法,发现只需要在命令行里输入qmake -help就有啦!
Usage: D:\Software\Qt\5.15.2\mingw81_64\bin\qmake.exe [mode] [options] [files]QMake has two modes, one mode for generating project files based on
some heuristics, and the other for generating makefiles. Normally you
shouldn't need to specify a mode, as makefile generation is the default
mode for qmake, but you may use this to test qmake on an existing projectMode:-project Put qmake into project file generation modeIn this mode qmake interprets [files] as files tobe added to the .pro file. By default, all files withknown source extensions are added.Note: The created .pro file probably willneed to be edited. For example add the QT variable tospecify what modules are required.-makefile Put qmake into makefile generation mode (default)In this mode qmake interprets files as project files tobe processed, if skipped qmake will try to find a projectfile in your current working directoryWarnings Options:-Wnone Turn off all warnings; specific ones may be re-enabled bylater -W options-Wall Turn on all warnings-Wparser Turn on parser warnings-Wlogic Turn on logic warnings (on by default)-Wdeprecated Turn on deprecation warnings (on by default)Options:* You can place any variable assignment in options and it will be ** processed as if it was in [files]. These assignments will be ** processed before [files] by default. *-o file Write output to file-d Increase debug level-t templ Overrides TEMPLATE as templ-tp prefix Overrides TEMPLATE so that prefix is prefixed into the value-help This help-v Version information-early All subsequent variable assignments will beparsed right before default_pre.prf-before All subsequent variable assignments will beparsed right before [files] (the default)-after All subsequent variable assignments will beparsed after [files]-late All subsequent variable assignments will beparsed right after default_post.prf-norecursive Don't do a recursive search-recursive Do a recursive search-set <prop> <value> Set persistent property-unset <prop> Unset persistent property-query <prop> Query persistent property. Show all if <prop> is empty.-qtconf file Use file instead of looking for qt.conf-cache file Use file as cache [makefile mode only]-spec spec Use spec as QMAKESPEC [makefile mode only]-nocache Don't use a cache file [makefile mode only]-nodepend Don't generate dependencies [makefile mode only]-nomoc Don't generate moc targets [makefile mode only]-nopwd Don't look for files in pwd [project mode only]
qmake有两种模式,一个是产生基于一些启发式的工程文件,另一个是产生makefiles。一般来说,你不需要特定设置一个模式,因为makefile的产生是qmake的默认模式,但是你也许可以通过特定设置模式在一个已经存在的工程中测试qmake。
模式:
-project 将源文件加入.pro文件中。默认地,所有具有已知地址的源文件会被加入。
Note: 创建的.pro文件很可能需要编辑,比如增加QT变量以设置所需要的模块。
参考链接:https://www.cnblogs.com/zhangleibo/p/5967560.html
https://blog.csdn.net/mybelief321/article/details/9208775
Qt学习 踩坑总结1相关推荐
- MAC-XXL_JOB学习踩坑记录-Failed to create parent directories for [/data/applogs/xxl-job/xxl-job-admin.log
MAC-XXL_JOB学习踩坑记录 源码下载地址 启动报错 源码下载地址 ①.GitHub:https://github.com/xuxueli/xxl-job ②.码云:https://gitee. ...
- cesium给地图添加比例尺学习踩坑记录
cesium给地图添加比例尺学习踩坑记录 因项目需要在cesium地图中展示比例尺,本来应该是很简单的事,但却碰到了一个引用文件的坑,特此记录: *1.引用依赖文件 相信需要用到cesium比例尺组件 ...
- sanic学习踩坑记录:第一坑——sanic_jinja2应用报错ModuleNotFoundError: No module named ‘AppName‘
刚开始学习使用sanic,发现有一些坑,随手记录一下:以供后来者共同学习,避免踩坑: # 使用的软件版本 python 3.8.10 sanic 21.9.3 sanic-jinja2 0.10.0 ...
- AIGC - Stable Diffusion 学习踩坑实录总结
学习路径 淘宝拼多多找教程就没必要了,我踩过坑,还跟店主纠缠过,付了钱,不过都退了,淘宝平台介入,啥都能解决,现在卖得都是搬运的 B 站里面的大佬视频,我目前正在不断关注 B 站大佬的各种课程,探索更 ...
- Pytorch深度学习踩坑记录
写这篇博文的主要目的是记录一下在使用Pytorch做深度学习项目时踩的一些坑,警醒自己,帮助他人
- iris学习踩坑之旅
1:iris的学习文档: https://studyiris.com/doc/irisDoc/Routing.html(翻译的比较好,版本问题,容易遇到坑我第一个问题就是在这个文档遇到的) https ...
- k8s学习 踩坑之 top nodes - k8s Metrics not available for pod 报错
最近一直在弄k8s,前面安装都要顺畅,包括K8S集群等等. k8s有个很重要的功能,就是它可以根据你服务器的压力动态扩容pod. 比如你可以预定你的pod实例是5个,当请求高峰过来的时候,pod压力过 ...
- SimpleDateFormat的相关学习踩坑记
转载至:ImportNew的<还在使用 SimpleDateFormat ?你的项目崩没?> 作者:周宇峰 突然看到ImportNew的相关推送,想起了以前踩过的坑,特此转载顺便记录一下. ...
- 学习踩坑:在Vue项目中使用svg标签却无法改变图标的颜色
在Vue项目中使用svg标签却无法改变图标的颜色 在学习 vue 实战项目的过程中,用到了 svg 模块,对其使用了 fill 属性后,图标的颜色却没有任何的改变,反复查看了视频,步骤是一模一样的,却 ...
最新文章
- 方案没效果,是方法有问题还是人有问题?
- Java创建cookie和删除cookie
- 使用MAP文件快速定位程序崩溃代码行(转)
- java堆栈类在哪个包里_Java堆栈Stack类的使用
- 使用C#Visual Studio2015编写Android应用程序详细步骤
- 泛微oa系统什么框架_泛微移动办公OA系统走进江苏国曜信息科技有限公司
- GB/T 8567-2006《计算机软件文档编制规范》中与需求有关的文档包
- Google Play 应用迁移
- 如何将class文件反编译成java文件
- 计算机课flash课件,初识flash动画教学课件
- 3.Regression(二)
- prometheus监控之postgresql
- 干货技巧:10个冲压工艺及模架设计知识点
- 克罗内克积【kronecker product】
- Latex算法命令\REQUIRE和\ENSURE显示为Input:和Output:
- php活体检测,人脸门禁系统中活体检测的必要性
- win10计算机图标怎么放桌面壁纸,图解win7、win10创意电脑桌面图标摆放的方法
- 解决ubantu里面报错findfont: Font family ['sans-serif'] not found. Falling back to Bitstream Vera Sans
- 计算机行业应该考哪些证书?
- OpenGL ES for Android 绘制旋转的地球