Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

qmake cannot locate any source or header files

Tags:

qt

qt5

qmake

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.

like image 451
Martin Drozdik Avatar asked Dec 21 '22 04:12

Martin Drozdik


2 Answers

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

like image 120
Suresh Namala Avatar answered Dec 28 '22 07:12

Suresh Namala


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

like image 31
Phlucious Avatar answered Dec 28 '22 07:12

Phlucious