错误:QApplication:没有这样的文件或目录 - Ubuntu 12.04 LTS

时间:2013-09-30 11:47:37

标签: qt qt-quick

Ubuntu 12.04 LTS

Qt版本:

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

.pro 档案:

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

.cpp 档案:

#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();
}

错误:

$ 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

2 个答案:

答案 0 :(得分:10)

这就是诀窍:

sudo apt-get install libqt4-dev

答案 1 :(得分:3)

对于Ubuntu 14.04,如果出现同样的错误:

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

尝试qmake-qt4,然后make。当然,如果QT4库不存在,你可以使用:

sudo apt-get install libqt4-dev