Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error: QApplication: No such file or directory - Ubuntu 12.04 LTS

Tags:

qt

qt-quick

Ubuntu 12.04 LTS

Qt version:

$ qmake -v
QMake version 2.01a
Using Qt version 4.8.1 in /usr/lib/x86_64-linux-gnu

.pro file:

TEMPLATE += app
QT += core gui declarative
SOURCES += qtCppIntegration.cpp

.cpp file:

#include <QApplication>
#include <QQuickView>
#include <QUrl>

int main (int argc, char *argv[])
{
  QApplication app(argc, argv);
  QQuickView view;
  view.setSource(QUrl("/home/...plesQtQuickQML/anchors.qml"));
  view.show();
  return app.exec();
}

error:

$ make
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_DECLARATIVE_LIB -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/QtDeclarative -I/usr/include/qt4 -I. -o qtCppIntegration.o qtCppIntegration.cpp
qtCppIntegration.cpp:1:24: fatal error: QApplication: No such file or directory
compilation terminated.
make: *** [qtCppIntegration.o] Error 1
like image 650
Aquarius_Girl Avatar asked Sep 30 '13 11:09

Aquarius_Girl


2 Answers

This did the trick:

sudo apt-get install libqt4-dev

like image 180
Aquarius_Girl Avatar answered Nov 02 '22 23:11

Aquarius_Girl


For Ubuntu 14.04 if you get the same error:

ABC$ make
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -I. -I. -I/usr/include/qt5 -I/usr/include/qt5/QtGui -I/usr/include/qt5/QtCore -I. -o textpad.o textpad.cpp
textpad.cpp:1:24: fatal error: QApplication: No such file or directory
 #include <QApplication>
                        ^
compilation terminated.
make: *** [textpad.o] Error 1

Try qmake-qt4 and then make. Of course you can get all the QT4 libraries if its not present using:

sudo apt-get install libqt4-dev 
like image 37
Roy Avatar answered Nov 03 '22 01:11

Roy