4

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.

The qmake suddenly cannot find any of my source or header files.

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/f.h exists in the same directory as untitled.pro. And I get this output from 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.

4

2 回答 2

7

当我在 pro 文件中包含 VPATH 时解决了相同的问题

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

同样对于 qt 5,我们不需要在 pro 文件中包含 DEPENDPATH

于 2014-12-17T17:18:10.033 回答
4

你从来没有定义过 PWD。双美元符号“$$”前缀表示之前在 pro 文件中定义的 qmake 变量。在你的情况下,这$$PWD部分是完全没有必要的。如果你完全删除它,一切都应该编译得很好。

编辑:此外,他们悄悄地改变DEPENDPATH了 Qt 5 中的行为。从 Qt 5 开始,现在在查找and ( )时qmake默认使用您的 s。只需放下线,你应该会很好。INCLUDEPATHSOURCESHEADERSconfig += depend_includepathDEPENDPATH

INCLUDEPATH += "Dir"

参考:.pro 文件中的 Qmake 变量

于 2013-06-21T23:18:03.417 回答