【问题标题】:Make Errors: Missing Includes in C++ Script?出错:C++ 脚本中缺少包含?
【发布时间】:2010-04-09 21:08:22
【问题描述】:

几分钟前,我刚刚在 SO 上获得了有关如何编译此脚本的帮助,但我设法得到了错误。我只是 C++ 的初学者,不知道下面的错误是什么意思或如何修复它。

这是script in question。我已经阅读了一些用户的 cmets 建议他们更改了 #include 部分,但这似乎正是脚本所具有的,see this comment

[root@localhost wkthumb]# qmake-qt4 && make
g++ -c -pipe -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/qt4/mkspecs/linux-g++ -I. -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include -I. -I. -I. -o main.o main.cpp
main.cpp:5:20: error: QWebView: No such file or directory
main.cpp:6:21: error: QWebFrame: No such file or directory
main.cpp:8: error: expected constructor, destructor, or type conversion before ‘*’ token
main.cpp:11: error: ‘QWebView’ has not been declared
main.cpp: In function ‘void loadFinished(bool)’:
main.cpp:18: error: ‘view’ was not declared in this scope
main.cpp:18: error: ‘QWebSettings’ has not been declared
main.cpp:19: error: ‘QWebSettings’ has not been declared
main.cpp:20: error: ‘QWebSettings’ has not been declared
main.cpp: In function ‘int main(int, char**)’:
main.cpp:42: error: ‘view’ was not declared in this scope
main.cpp:42: error: expected type-specifier before ‘QWebView’
main.cpp:42: error: expected `;' before ‘QWebView’
make: *** [main.o] Error 1

我的 Fedora Core 10 机器上有 Web 工具包: qt-4.5.3-9.fc10.i386 qt-devel-4.5.3-9.fc10.i386

感谢大家的帮助

【问题讨论】:

  • 你使用的是同一个wkthumb.pro吗?
  • @gf - 是的,我是。需要修改吗?

标签: c++ linux makefile qmake


【解决方案1】:

错误消息表明编译器找不到您要包含的内容,即<QWebView>。告诉编译器在哪里查找的方法是使用 -I 标志,指定包含目录(这些不是递归的)。

目前,您设置了以下包含目录:

  • -I/usr/lib/qt4/mkspecs/linux-g++
  • -I.
  • -I/usr/include/QtCore
  • -I/usr/include/QtGui
  • -I/usr/include

您需要找到QWebView 在您的系统上的位置,并将包含路径添加到命令行(或将QWebView 安装到上述目录之一)。

一般注意事项:当您遇到很多此类错误时,请关注前一两个错误。后面的错误(如‘QWebView’ has not been declared)可能会通过修复missing-include错误来解决。

【讨论】:

    【解决方案2】:
    main.cpp:18: error: ‘view’ was not declared in this scope
    

    看起来必须在代码中提供命名空间。阅读命名空间。

    main.cpp:20: error: ‘QWebSettings’ has not been declared
    

    没有可用的类型定义,可能缺少包含。

    【讨论】:

    • "QWebView: No such file or directory" - 未找到 Web 视图包含文件。
    • 推论:first 错误总是最重要的。我通常什至不看后续错误,因为它们通常是后续错误,当第一个错误的原因得到解决后就会消失。
    猜你喜欢
    • 1970-01-01
    • 2018-05-24
    • 1970-01-01
    • 2018-05-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-10
    • 1970-01-01
    相关资源
    最近更新 更多