简体   繁体   English

qmake找不到任何源文件或头文件

[英]qmake cannot locate any source or header files

I am trying to bring my project from one computer with qt4 to another where I freshly installed qt5 and I am having a very strange problem. 我试图将我的项目从qt4一台计算机带到另一台新安装的qt5 ,我有一个非常奇怪的问题。

The qmake suddenly cannot find any of my source or header files. qmake突然找不到我的任何源文件或头文件。

Here is a minimalist example: 这是一个极简主义的例子:

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = untitled
TEMPLATE = app


SOURCES += main.cpp\
        mainwindow.cpp

INCLUDEPATH += $$PWD/Dir/
DEPENDPATH += $$PWD/Dir/

HEADERS  += mainwindow.h \
    f.h \

FORMS    += mainwindow.ui

Where Dir/fh exists in the same directory as untitled.pro . 其中Dir/fhuntitled.pro位于同一目录中。 And I get this output from qmake: 我从qmake得到这个输出:

05:18:45: Starting: "/opt/QtSDK/5.0.2/gcc/bin/qmake" 
/home/martin/Projects/untitled/untitled.pro 
-r -spec linux-g++ CONFIG+=debug CONFIG+=declarative_debug CONFIG+=qml_debug
WARNING: Failure to find: f.h
05:18:45: The process "/opt/QtSDK/5.0.2/gcc/bin/qmake" exited normally.

I have absolutely no idea what is causing this. 我完全不知道造成这种情况的原因。 What could be the problem? 可能是什么问题呢?

EDIT: 编辑:

When I manually prepend the name like this: 当我手动添加这样的名称时:

HEADERS += Dir/f.h \

qmake doesn't complain. qmake不抱怨。

The Same issue solved when I include VPATH in pro file 当我在VP文件中包含VPATH时,同样的问题就解决了

Eg: VPATH += ../../libraries/ INCLUDE += ../../libraries/ 例如:VPATH + = ../../libraries/ INCLUDE + = ../../libraries/

Also with qt 5 we need not to include DEPENDPATH in pro files 另外,对于qt 5,我们不需要在pro文件中包含DEPENDPATH

You never defined PWD. 你从未定义过PWD。 The double-dollar sign '$$' prefix indicates a qmake variable defined earlier in the pro file. 双美元符号'$$'前缀表示先前在pro文件中定义的qmake变量。 In your case, the $$PWD portion is completely unnecessary. 在您的情况下, $$PWD部分是完全没必要的。 If you remove it entirely, everything should compile just fine. 如果你完全删除它,一切都应该编译得很好。

Edit: Additionally, they quietly changed DEPENDPATH behavior in Qt 5 . 编辑:此外, 他们在Qt 5中悄然改变了DEPENDPATH行为 As of Qt 5, qmake now defaults to using your INCLUDEPATH s when looking for the SOURCES and HEADERS ( config += depend_includepath ). 从Qt 5开始, qmake现在默认使用你的INCLUDEPATH来寻找SOURCESHEADERSconfig += depend_includepath )。 Simply drop the DEPENDPATH line and you should be good. 只需放下DEPENDPATH线就可以了。

INCLUDEPATH += "Dir"

Reference: Qmake variables in .pro files 参考: .pro文件中的Qmake变量

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM