Search code examples
qtcompilationqmake

qmake missing object file


Alright... So I am very new to Qt. I just installed it on my Ubuntu distribution. I created a new test application to see if it worked with the following file (helloworld.cpp) in my ../helloworld/ directory:

/*  helloworld.cpp */
#include <QApplication>
#include <QWidget>

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QWidget window;

    window.resize(250, 150);
    window.setWindowTitle("Simple example");
    window.show();

    return app.exec();
}

and I ran qmake -project in order to generate the helloworld.pro file. Next I ran qmake in order to genereate the Makefile Next I ran make in order to compile and got the following output/error:

g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG 
-DQT_GUI_LIB -DQT_CORE_LIB -I/usr/share/qt4/mkspecs/linux-g++-64 -I. 
-I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 
-I. -I. -o helloworld.o helloworld.cpp
helloworld.cpp:1:24: fatal error: QApplication: No such file or directory
compilation terminated.
make: *** [helloworld.o] Error 1

meaning the helloworld.o file is missing... How do I fix this? I tried adding QT += webkit as another discussion said... and that didn't work either.

Any code monkeys out there have any ideas how to fix this??? I would greatly appreciate it!


Solution

  • QApplication should be inside /usr/include/qt4/QtGui, provided you have installed the libqt4-dev package. If that package is not installed, that's the reason of the error: just install it:

    sudo apt-get install libqt4-dev