Wednesday, February 8, 2012

Error : QtCore : No such file or directory


This error occurs in a Qt project when #include <QtCore> is used in the header files of your project. QtCore is a part of Qt 4  and not available for Qt 3.3.So inoredr to use Qtcore , Qt4 needs to be installed in your system. Qt 3.3 and Qt 4 can be available in the same system ; i.e these 2 can co-exist in the same system. Even if Qt 4 is installed in your system , the error occurs.

The question is , how to correct this?

When you use the file QtCore in your header files , you need to set the path in your project directory. To know the present directory path , go to your project directory and just type echo $QTDIR in command prompt , press enter. you can see its default set to qt3.3. So just type these 3 in command prompt after you change to your project directory.

i)

ii)

iii)

Now again type echo $QTDIR , you can see the path settings now point to qt4.

After this, instead of qmake to create the Makefile , type qmake-qt4 <.pro file>. Also , include a statement QT+= core in your .pro file.

The error will disappear!!!

No comments:

Post a Comment