C++ QApplication:Windows 上没有 Qt5 和 qtsingleapplication 这样的文件或目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15290742/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
QApplication: No such file or directory with Qt5 and qtsingleapplication on windows
提问by Sébastien Bémelmans
I have trouble to compile on windows since I move on QT 5.0.1 (from http://qt-project.org/downloads) and the module qtsingleapplication (last version from http://qt.gitorious.org/qt-solutions).
自从我使用 QT 5.0.1(来自http://qt-project.org/downloads)和模块 qtsingleapplication(来自http://qt.gitorious.org/qt-solutions 的最新版本)以来,我无法在 Windows 上进行编译)。
Under Linux, the compilation still working (Qt 4.8.2)
在 Linux 下,编译仍然有效(Qt 4.8.2)
I dont understand why. This is the detailed output from qtcreator.
我不明白为什么。这是 qtcreator 的详细输出。
09:57:58: Exécution des étapes pour le projet Wahoo...
09:57:58: Configuration inchangée, étape QMake sautée.
09:57:58: Débute : "D:\Qt\Qt5.0.1\Tools\MinGW\bin\mingw32-make.exe"D:/Qt/Qt5.0.1/Tools/MinGW/bin/mingw32-make -f Makefile.Release
mingw32-make[1]: Entering directory 'C:/Documents and Settings/crazy/Bureau/Kowmedia.Wahoo/src/Build-Release/release'g++ -c -pipe -fno-keep-inline-dllexport -O2 -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_NO_DEBUG -DQT_WEBKIT_LIB -DQT_WIDGETS_LIB -DQT_XML_LIB -DQT_NETWORK_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_OPENGL_ES_2 -DQT_OPENGL_ES_2_ANGLE -DQT_NEEDS_QMAIN -I....\wahoo -I"....\wahoo\qtsingleapplication\src" -I"D:\Qt\Qt5.0.1\5.0.1\mingw47_32\include" -I"D:\Qt\Qt5.0.1\5.0.1\mingw47_32\include\QtWebKit" -I"D:\Qt\Qt5.0.1\5.0.1\mingw47_32\include\QtWidgets" -I"D:\Qt\Qt5.0.1\5.0.1\mingw47_32\include\QtXml" -I"D:\Qt\Qt5.0.1\5.0.1\mingw47_32\include\QtNetwork" -I"D:\Qt\Qt5.0.1\5.0.1\mingw47_32\include\QtGui" -I"D:\Qt\Qt5.0.1\5.0.1\mingw47_32\include\QtCore" -I"release" -I"." -I"." -I"D:\Qt\Qt5.0.1\5.0.1\mingw47_32\mkspecs\win32-g++" -o release\qtsingleapplication.o ....\wahoo\qtsingleapplication\src\qtsingleapplication.cpp
g++ -pipe -fno-keep-inline-dllexport -O2 -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_NO_DEBUG -DQT_WEBKIT_LIB -DQT_WIDGETS_LIB -DQT_XML_LIB -DQT_NETWORK_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_OPENGL_ES_2 -DQT_OPENGL_ES_2_ANGLE -DQT_NEEDS_QMAIN ../../wahoo/qtsingleapplication/src/qtsingleapplication.cpp -o ../../wahoo/qtsingleapplication/src/QtSingleApplication
In file included from ../../wahoo/qtsingleapplication/src/qtsingleapplication.cpp:42:0:
../../wahoo/qtsingleapplication/src/qtsingleapplication.h:44:24: fatal error: QApplication: No such file or directorycompilation terminated.
<builtin>: recipe for target '../../wahoo/qtsingleapplication/src/QtSingleApplication' failed
mingw32-make[1]: ** [../../wahoo/qtsingleapplication/src/QtSingleApplication] Error 1
mingw32-make[1]: Leaving directory 'C:/Documents and Settings/crazy/Bureau/Kowmedia.Wahoo/src/Build-Release/release'
makefile:34: recipe for target 'release' failed
mingw32-make: ** [release] Error 2
09:57:59: Le processus "D:\Qt\Qt5.0.1\Tools\MinGW\bin\mingw32-make.exe" s'est terminé avec le code 2.
Error while building/deploying project Wahoo (kit: Desktop Qt 5.0.1 MinGW 32bit) Lors de l'exécution de l'étape "Make"
09:57:58:Exécution des étapes pour le projet Wahoo...
09:57:58:配置更改,étape QMake sautée。
09:57:58:首次亮相:“D:\Qt\Qt5.0.1\Tools\MinGW\bin\mingw32-make.exe”D:/Qt/Qt5.0.1/Tools/MinGW/bin/mingw32-make -f Makefile.Release
mingw32-make[1]: 进入目录'C:/Documents and Settings/crazy/Bureau/Kowmedia.Wahoo/src/构建-发布/发布'克++ -c -pipe -fno-保直列DLLEXPORT -O2 -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_NO_DEBUG -DQT_WEBKIT_LIB -DQT_WIDGETS_LIB -DQT_XML_LIB -DQT_NETWORK_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_OPENGL_ES_2 -DQT_OPENGL_ES_2_ANGLE -DQT_NEEDS_QMAIN -I。 ...\wahoo -I"....\wahoo\qtsingleapplication\src" -I"D:\Qt\Qt5.0.1\5.0.1\mingw47_32\include" -I"D:\Qt\Qt5.0.1 \5.0.1\mingw47_32\include\QtWebKit" -I"D:\Qt\Qt5.0.1\5.0.1\mingw47_32\include\QtWidgets" -I"D:\Qt\Qt5.0.1\5.0.1\mingw47_32 \include\QtXml" -I"D:\Qt\Qt5.0.1\5.0.1\mingw47_32\include\QtNetwork" -I"D:\Qt\Qt5.0.1\5.0.1\mingw47_32\include\QtGui" - I"D:\Qt\Qt5.0.1\5.0.1\mingw47_32\include\QtCore" -I"release" -I"." -一世”。” -I"D:\Qt\Qt5.0.1\5.0.1\mingw47_32\mkspecs\win32-g++"
克++ -pipe -fno-保直列DLLEXPORT -O2 -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_NO_DEBUG -DQT_WEBKIT_LIB -DQT_WIDGETS_LIB -DQT_XML_LIB -DQT_NETWORK_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_OPENGL_ES_2 -DQT_OPENGL_ES_2_ANGLE -DQT_NEEDS_QMAIN ../ .. /wahoo/qtsingleapplication/src/qtsingleapplication.cpp -o ../../wahoo/qtsingleapplication/src/QtSingleApplication
在 ../../wahoo/qtsingleapplication/src/qtsingleapplication.cpp:42:0:
../../wahoo/qtsingleapplication/src/qtsingleapplication.h:44:24包含的文件中:致命错误:QApplication:否这样的文件或目录编译终止。
<builtin>:目标'../../wahoo/qtsingleapplication/src/QtSingleApplication'的配方失败
mingw32-make[1]:** [../../wahoo/qtsingleapplication/src/QtSingleApplication] 错误1
mingw32 -make[1]: 离开目录 'C:/Documents and Settings/crazy/Bureau/Kowmedia.Wahoo/src/Build-Release/release'
makefile:34: 目标 'release' 的配方失败
mingw32-make: ** [ release] Error 2
09:57:59: Le processus "D:\Qt\Qt5.0.1\Tools\MinGW\bin\mingw32-make.exe" s'est terminé avec le code 2.
构建/部署项目Wahoo时出错(套件:桌面 Qt 5.0.1 MinGW 32 位) Lors de l'execution de l'étape "Make"
Every files are presents, the option -I"D:\Qt\Qt5.0.1\5.0.1\mingw47_32\include\QtWidgets" too. QtCreator can find the file if I browse from the source code. So I'm a bit lost ...
每个文件都存在,选项 -I"D:\Qt\Qt5.0.1\5.0.1\mingw47_32\include\QtWidgets" 也是。如果我从源代码浏览,QtCreator 可以找到该文件。所以我有点失落......
Thank you in advance
先感谢您
回答by Denjs
...QApplication: No such file or directory ...
...QApplication:没有这样的文件或目录...
try to add
尝试添加
QT += widgets
at your .pro file. I had the same message... It looks like from 5.0 Qt-based applications does not like widgets by default... Are everybody moved to QML ?
在您的 .pro 文件中。我有同样的消息......看起来基于 5.0 的基于 Qt 的应用程序默认不喜欢小部件......每个人都转移到 QML 了吗?
PS: now, as the next point in this quest - I have QPrinter to be not found )
PS:现在,作为这个任务的下一个点 - 我没有找到 QPrinter )
回答by quetzalcoatl
It suggests that you have incorrectly configured library search paths in your IDE. The QT SDK libraries are not found. Have you installed everything using the QT tools and/or the installation manual?
这表明您在 IDE 中错误地配置了库搜索路径。未找到 QT SDK 库。您是否使用 QT 工具和/或安装手册安装了所有内容?
"QApplication" is one of the header files, included by #include <qapplication>
. Depending on how and which SDK you installed, it may reside for example:
“QApplication”是头文件之一,包含在#include <qapplication>
. 根据您安装的 SDK 的方式和安装方式,它可能驻留在例如:
Nokia SDK with Carbide/Eclipse:
带有 Carbide/Eclipse 的诺基亚 SDK:
C:\????\Nokia\devices\Nokia_Symbian_Belle_SDK_v1.0\epoc32\include\mw\qtgui
QtCreator and QT SDK installer:
QtCreator 和 QT SDK 安装程序:
C:\????\QtSDK\Symbian\SDKs\SymbianSR1Qt474\include\QtGui
where ???? stands for the location you've chosen when installing the tools. First, check it you have the file.
在哪里 ????代表您在安装工具时选择的位置。首先,检查它是否有文件。
It you have it, and if it is undamaged, and if you have not mistaken driveletters etc, then check your QT Project files and check if you really have all the imports and includes set correctly. Maybe you forgot some "\include" suffix, or maybe you have one too much? LINUX and WIN32 build configs usually differ in many settings, it's very easy to accidentially mix some conditionals that set up the paths
如果你有它,如果它没有损坏,如果你没有弄错驱动器等,那么检查你的 QT 项目文件并检查你是否真的正确设置了所有导入和包含。也许您忘记了一些“\include”后缀,或者您的后缀太多了?LINUX 和 WIN32 构建配置通常在许多设置上有所不同,很容易不小心混合一些设置路径的条件
EDIT:
编辑:
Thanks for the update! Paths indeed look OK
感谢更新!路径确实看起来不错
I've re-read your error log, and everything looked fine until I re-formatted it a little. Something strange popped out. Please look at the first G++ call and compare it witl the second one that fails.
我重新阅读了你的错误日志,一切看起来都很好,直到我重新格式化了一点。奇怪的东西冒了出来。请查看第一个 G++ 调用并将其与第二个失败的调用进行比较。
The second one lacks all the paths setups. But this is normal. The first one performs compilation, the second one is linking. Distinguishable by the g++ -c
versus g++
wihtout "-c" parameter. But look at the FILES passed to G++.
第二个缺少所有路径设置。但这是正常的。第一个执行编译,第二个执行链接。可以通过g++ -c
与g++
没有“-c”参数来区分。但是看看传递给 G++ 的 FILES。
The first one compiles qtsingleapplication.cpp
into qtsingleapplication.o
, while the second tries to link qtsingleapplication.cpp
into -o QtSingleApplication
.
第一个编译qtsingleapplication.cpp
为qtsingleapplication.o
,而第二个尝试链接qtsingleapplication.cpp
到-o QtSingleApplication
.
I think that:
我觉得:
- either the second line forgot the parameter "-c" and all the
-I
paths - or the second line has invalid input file and should have
qtsingleapplication.o
instead of.cpp
- 要么第二行忘记了参数“-c”和所有
-I
路径 - 或者第二行有无效的输入文件,应该有
qtsingleapplication.o
而不是.cpp
I guess that you really have some switches/conditional messed up in your qtprojs for the :win32 cases.. I'm sorry I cannot tell you more, at this point, I'd have to try compiling the project myself and investigate the makefiles/qtprojs. Try backtracing how the second line gets generated and what makefile/qtproj variables are used, and then double- or even triple-check your project settings. Do it not in the IDE, but in the actual project files that are used. IDE sometimes hides some conditions and setups from you, especially QT Creator likes to do that..
我想你的 qtprojs 中确实有一些开关/条件搞砸了 :win32 案例..很抱歉我不能告诉你更多,在这一点上,我不得不尝试自己编译项目并调查 makefile /qtprojs. 尝试回溯第二行是如何生成的以及使用了哪些 makefile/qtproj 变量,然后仔细检查您的项目设置。不要在 IDE 中执行此操作,而是在使用的实际项目文件中执行此操作。IDE 有时会向您隐藏一些条件和设置,尤其是 QT Creator 喜欢这样做..
回答by gollumullog
I also encountered this issue.
我也遇到了这个问题。
Once I added
一旦我添加
QT += widgets
like Denjs suggested, I also needed to add:
就像 Denjs 建议的那样,我还需要添加:
INCLUDEPATH += $$PWD/../qtsingleapplication-2.6-opensource/src/
Which is the location of the QtSingleApplication source files.
这是 QtSingleApplication 源文件的位置。
回答by Sublele
I'm new to Qt. And when i try the first program,after qmake -project qmake hello.pro
我是 Qt 的新手。当我尝试第一个程序时,在 qmake -project qmake hello.pro 之后
there appeared a mistake after 'make': 'QApplication'file not found
'make'后出现错误:'QApplication'file not found
but with the same code,it can debug successfully on Qt Creator. the same mistake occured when i want to release it.
但是使用相同的代码,它可以在 Qt Creator 上成功调试。当我想释放它时发生了同样的错误。
the solution is to modify the .pro file. Add the following two line:
解决办法是修改.pro文件。添加以下两行:
QT += core gui
QT += 核心 gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
GreaterThan(QT_MAJOR_VERSION, 4):QT += 小部件