c++ - QAbstractSocket 没有那个文件或目录

标签 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'

最佳答案

如果项目路径包含空格或非 ASCII 字符,Qt 构建可能会失败。

Documentation提到你不应该将 Qt 安装到包含空格的目录中,但应该更好地记录它并明确警告你的项目路径也可能影响构建过程。

在您的情况下,包含路径设置为相对于项目路径(例如,-I"..\..\..\..\..\Qt\Qt5.0.0\5.0.0\msvc2010\include\QtGui),其中包含空格,因此 cl 无法找到 header 。

Related question:
The process qmake.exe exited with code 2 - first time with Qt and Qt Creator

关于c++ - QAbstractSocket 没有那个文件或目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14132369/

相关文章:

c++ - 基本 boost :pyton program 中的 undefined reference

qt - 如何在QTableView中选择行?

c++ - 可以在 C++ 中隐藏部分继承层次结构吗?

compiler-errors - (...)*构造中的JAVACC ERROR选择冲突

c++ - 格式化十进制为 float

c++ - 设置 iOS 项目以使用 eigen

java - 使用占碑创建自定义日历

flash - 无法解析<local :chatters> to a component implementation

c++ - “类”在这里有一个先前的声明

c++ - 如何在 C++ 中检测 segv