4
我刚刚开始使用Qt(使用C++),所以我遵循我在网上找到的“hello,world”示例。我创建的程序HELLO.CPP目录您好:QtWebKit依赖项从qmake生成的Makefile中缺少
#include <QtGui>
int main(int argc, char *argv[]) {
QApplication app (argc, argv);
QLabel label ("Hello, world!");
label.show();
return app.exec();
}
我跑:
qmake -project
qmake hello.pro
make
,一切都正确编译和我能够./hello运行。然后,作为一个喜欢冒险的人,我试图修改文件:
#include <QtGui>
#include <QtWebKit>
int main(int argc, char *argv[]) {
QApplication app (argc, argv);
QLabel label ("Hello, world!");
QWebPage page;
label.show();
return app.exec();
}
我重新运行三个命令,但现在当我运行make我得到以下错误:
hello.cpp:2: fatal error: QtWebKit: No such file or directory
compilation terminated.
make: *** [hello.o] Error 1
我检查了的Makefile并且INCPATH变量被定义为
INCPATH = -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I.
它明显缺少-I/usr/include/qt4/QtWebKit。 LIBS变量也缺少-lQtWebKit。手动添加这些将导致编译成功。我究竟做错了什么?我需要添加什么来使qmake生成正确的Makefile?
感谢。 “QT + = webkit”是标准格式吗?如果我想添加QtXml,我也会把“QT + = xml”,或者“QT + = webkit,xml”? – Nick
@Nick:更新了我的答案 – Mat