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.

Martin Drozdik
  • 12,742
  • 22
  • 81
  • 146
  • I don't understand why you don't understand. =). If f.h is in the folder Dir then you need to add the full path to that file. Which is why HEADERS += Dir/f.h works. Does that make sense? – Son-Huy Pham Jun 21 '13 at 21:20
  • 2
    @Huytard but I did not need to do this before. I would just add the directory: DEPENDPATH += $$PWD/Dir/ and then I do not need to write the full paths. Why is this suddenly a problem is making me mad. – Martin Drozdik Jun 21 '13 at 21:29

2 Answers2

7

The Same issue solved when I include VPATH in pro file

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

Also with qt 5 we need not to include DEPENDPATH in pro files

Suresh Namala
  • 306
  • 4
  • 14
4

You never defined PWD. The double-dollar sign '$$' prefix indicates a qmake variable defined earlier in the pro file. In your case, the $$PWD portion is completely unnecessary. If you remove it entirely, everything should compile just fine.

Edit: Additionally, they quietly changed DEPENDPATH behavior in Qt 5. As of Qt 5, qmake now defaults to using your INCLUDEPATHs when looking for the SOURCES and HEADERS (config += depend_includepath). Simply drop the DEPENDPATH line and you should be good.

INCLUDEPATH += "Dir"

Reference: Qmake variables in .pro files

Community
  • 1
  • 1
Phlucious
  • 3,704
  • 28
  • 61
  • Thank you, but the result is the same. – Martin Drozdik Jun 22 '13 at 00:01
  • Does removing the extra \ after `f.h` fix it? – Phlucious Jun 22 '13 at 00:09
  • Nevermind. Try removing the DEPENDPATH line altogether and read this link: http://stackoverflow.com/questions/16769541/does-a-qt-5-programmer-have-to-know-about-dependpath-qmake-variable – Phlucious Jun 22 '13 at 00:14
  • 2
    INCLUDEPATH has nothing to do with finding files for SOURCES/HEADERS, but with resolving includes at compile time. HEADERS += Dir/f.h is the way to go. That DEPENDPATH thing was probably an unintended side-effect in Qt4. – Frank Osterfeld Jun 22 '13 at 07:49