QAbstractSocket没有这样的文件或目录

时间:2013-01-03 02:45:36

标签: c++ qt compiler-errors spaces

我是QT编程的新手,这让我感到困惑。我已经搜索了这个问题的答案,但我找到的答案并没有解决我的问题。通常,我在网上找到的答案是将QT += network添加到我的.pro文件中。但是我已经在我的.pro文件中使用了它,并且尚未修复。

有什么建议吗?

.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'

1 个答案:

答案 0 :(得分: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