2010-04-09 55 views
2

我剛剛在如何在幾分鐘前編譯這個腳本的幫助,但我已經設法得到錯誤。我只是C++的初學者,不知道下面的錯誤是什麼意思或如何解決它。錯誤:在C++腳本中缺少包含?

這是script in question。我已經閱讀了一些用戶的意見,建議他們更改#include部件,但它似乎正是腳本的內容,see this comment

[[email protected] 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 

我有web工具包我的Fedora Core 10臺機器上: QT-4.5.3-9.fc10.i386 QT-devel的-4.5.3-9.fc10.i386

謝謝所有的幫助

+0

您是否使用了相同的'wkthumb.pro'? – 2010-04-09 22:22:44

+0

@gf - 是的,我是。我需要修改它嗎? – Abs 2010-04-10 18:46:27

回答

1

錯誤消息表明編譯器找不到您要包含的內容,即<QWebView>。用-I標誌來告訴編譯器在哪裏查找的方式來指定include目錄(這些不是遞歸的)。

目前,你設置以下include目錄:

  • -I/usr/lib目錄/ QT4/mkspecs/Linux的G ++
  • -I。
  • -I/usr/include目錄/ QtCore
  • -I/usr/include目錄/ QtGui
  • -I/usr/include目錄

你需要找到QWebView位於您的系統上,並將包含路徑添加到命令行(或將QWebView安裝到上述dirs中的一箇中)。

一般注意事項:當你收到很多像這樣的錯誤時,請關注第一或第二。後面的錯誤(如‘QWebView’ has not been declared)可能會通過修復missing-include錯誤來解決。

0
main.cpp:18: error: ‘view’ was not declared in this scope 

看起來像命名空間必須在代碼中提供。閱讀命名空間。

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

沒有類型定義可用,可能會丟失include。

+0

*「QWebView:沒有這樣的文件或目錄」* - 沒有找到Web視圖包含文件。 – 2010-04-09 21:34:18

+0

Corrolary:**第一個**錯誤總是重要的。我通常甚至沒有看到隨後的錯誤,因爲它們通常是後續錯誤,當第一個錯誤的原因得到解決時消失。 – DevSolar 2012-06-26 09:48:30