2013-01-03 52 views
2

我是QT編程新手,這讓我感到困惑。我已經搜索了這個問題的答案,但我發現的答案並沒有解決我的問題。通常,我在網上找到的答案是說要將QT += network添加到我的.pro文件。但是我已經在我的.pro文件中有這個,並且它還沒有被修復。QAbstractSocket沒有這樣的文件或目錄

有什麼建議嗎?

.pro文件

QT  += core gui network 

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 

TARGET = firstproject 
TEMPLATE = app 


SOURCES += main.cpp\ 
    mainwindow.cpp \ 
IB_API_with_Qt/src/IBClient.cpp \ 
IB_API_with_Qt/src/EQtClientSocket.cpp \ 
IB_API_with_Qt/src/EClientSocketBase.cpp 

HEADERS += mainwindow.h \ 
IB_API_with_Qt/include/TwsSocketClientErrors.h \ 
IB_API_with_Qt/include/ScannerSubscription.h \ 
IB_API_with_Qt/include/OrderState.h \ 
IB_API_with_Qt/include/Order.h \ 
IB_API_with_Qt/include/IBClient.h \ 
IB_API_with_Qt/include/Execution.h \ 
IB_API_with_Qt/include/EWrapper.h \ 
IB_API_with_Qt/include/EQtClientSocket.h \ 
IB_API_with_Qt/include/EClientSocketBaseImpl.h \ 
IB_API_with_Qt/include/EClientSocketBase.h \ 
IB_API_with_Qt/include/EClient.h \ 
IB_API_with_Qt/include/Contract.h \ 
IB_API_with_Qt/include/CommonDefs.h 

FORMS += mainwindow.ui 

在那裏說只是在頭文件時出現錯誤:

#include <QAbstractSocket> 

而這正是編譯輸出提供我:

21:36:05: Running steps for project firstproject... 
21:36:05: Configuration unchanged, skipping qmake step. 
21:36:05: Starting: "C:\Qt\Qt5.0.0\Tools\QtCreator\bin\jom.exe" 
    C:\Qt\Qt5.0.0\Tools\QtCreator\bin\jom.exe -f Makefile.Debug 
    cl -c -nologo -Zm200 -Zc:wchar_t -Zi -MDd -GR -W3 -w34100 -w34189 -EHsc -DUNICODE -DWIN32 -DQT_QML_DEBUG - 
    DQT_DECLARATIVE_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_OPENGL_ES_2 -DQT_OPENGL_ES_2_ANGLE -I"..\..\.. 
    \..\..\Qt\Qt5.0.0\5.0.0\msvc2010\include" -I"..\..\..\..\..\Qt\Qt5.0.0\5.0.0\msvc2010\include\QtWidgets" -I"..\..\.. 
    \..\..\Qt\Qt5.0.0\5.0.0\msvc2010\include\QtGui" -I"..\..\..\..\..\Qt\Qt5.0.0\5.0.0\msvc2010\include\QtCore" -I"debug" 
    -I"." -I"." -I"..\..\..\..\..\Qt\Qt5.0.0\5.0.0\msvc2010\mkspecs\win32-msvc2010" -Fodebug\ @C:\Users\Terence\AppData 
    \Local\Temp\mainwindow.obj.5272.47.jom 
    mainwindow.cpp 
    c:\users\terence\documents\qt projects\firstproject\IB_API_with_Qt/include/IBClient.h(6) : fatal error C1083: Cannot 
    open include file: 'QAbstractSocket': No such file or directory 
    jom: C:\Users\Terence\Documents\QT Projects\firstproject-build-Desktop_Qt_5_0_0_MSVC2010_32bit_SDK-Debug 
    \Makefile.Debug [debug\mainwindow.obj] Error 2 
    jom: C:\Users\Terence\Documents\QT Projects\firstproject-build-Desktop_Qt_5_0_0_MSVC2010_32bit_SDK-Debug\Makefile 
    [debug] Error 2 
21:36:08: The process "C:\Qt\Qt5.0.0\Tools\QtCreator\bin\jom.exe" exited with code 2. 
    Error while building/deploying project firstproject (kit: Desktop Qt 5.0.0 MSVC2010 32bit (SDK)) 
    When executing step 'Make' 
+0

您使用QT版本大於4?如果是這樣,你可能需要在這一行添加'network' - >'moreThan(QT_MAJOR_VERSION,4):QT + = widgets'。 –

+0

@d_vj我正在使用QT大於4,但我只是嘗試了這個建議,仍然是同樣的問題 –

+0

問題可能是目錄'QT Projects'包含空格。嘗試將其重命名爲例如'QtProjects'。請參閱http://stackoverflow.com/questions/14095889/the-process-qmake-exe-exited-with-code-2-first-time-with-qt-and-qt-creator – doc

回答

1

如果項目路徑包含空格或非ASCII字符,Qt編譯可能會失敗。

Documentation提到,你不應該安裝的Qt到含有空格的目錄,但它應該是更好地記錄,並明確警告說,你的項目路徑可能會影響構建過程中也是如此。

在你的情況下,包含路徑被設置爲相對於項目路徑(例如,-I"..\..\..\..\..\Qt\Qt5.0.0\5.0.0\msvc2010\include\QtGui),其中包含空間,因爲cl無法找到標題。

相關問題:
The process qmake.exe exited with code 2 - first time with Qt and Qt Creator

相關問題