16

我的 .pro 文件中有以下内容,并且我有以下文件,#include "headerhere".例如: #include "StdAfx.h". 但是我得到了一个

错误无法打开包含文件:“StdAfx.h”:没有这样的文件或目录。

无论我使用#include "StdAfx.h"或,我都会遇到相同的错误#include "Shared/StdAfx.h"。这非常令人沮丧,除非 Qt 开始识别我的标题,否则我无法做任何实际工作。我在网上发现没有解决方案。到底是怎么回事?

.pro 文件有:

HEADERS  += ibproject.h \
Shared/StdAfx.h \
Shared/TwsSocketClientErrors.h \
Shared/TagValue.h \
Shared/shared_ptr.h \
Shared/ScannerSubscription.h \
Shared/OrderState.h \
Shared/Order.h \
Shared/IBString.h \
Shared/HScrollListBox.h \
Shared/Execution.h \
Shared/EWrapper.h \
Shared/EClientSocketBaseImpl.h \
Shared/EClientSocketBase.h \
Shared/EClient.h \
Shared/Contract.h \
Shared/CommonDefs.h \
Shared/CommissionReport.h \
SocketClient/src/EClientSocket.h
ewrappersubclass.h 

INCLUDEPATH += $$PWD/SocketClient
DEPENDPATH += $$PWD/SocketClient

编辑:为什么我会被否决?这是我遇到的合法问题

显示它识别和不同时识别的图像

4

7 回答 7

13

我也有同样的问题。原因是我并行使用两台计算机,makefile 试图在路径中查找文件,因为它们是在前一台计算机上设置的。但一切似乎都很好 - 就像你的情况一样,将鼠标悬停在包含上时的工具提示向我显示了正确的路径,F2(跟随光标下的符号)也将我导航到了正确的标题。

我认为每次更改 .pro 文件中的某些内容时都会重新制作 qmake,但显然不是。

只需运行 Build->qmake,它应该可以修复它。

于 2014-12-07T22:17:23.553 回答
9

您需要更新 q​​make 文件。

Build-> Run qmake
于 2013-11-26T16:53:51.413 回答
2

添加 .pro INCLUDEPATH += $$_PRO_FILE_PWD_

于 2015-01-29T09:05:11.220 回答
1

我不时遇到这个问题,主要是在我提出拉取请求或复制代码时。

简单的解决方案是删除所有 qt 生成的文件,然后 Build->qmake 然后全部重建。

这是一个 Qt 错误,它无法正确识别需要重新生成的文件,即使 IDE 很好地链接了所有内容,该错误也会在编译时发生。当它生成 ui_formname.h 头文件时也会发生同样的情况,某些更改不会立即生效。

有时,需要重新启动 QtCreator。执行删除和重新启动总是可以解决这个确切的问题。

祝你今天过得愉快!

于 2018-03-08T07:45:33.023 回答
0

The file is not in your include path.

The HEADERS part of a pro file lists header files that the project depends on. These files are considered for processing by moc if they have the Q_OBJECT macro in the class definition. Adding a file to HEADERS does not put it in the include search path.

You also have a stray header (ewrappersubclass.h) because you forgot to escape the end of line.

I suspect that the reason for this is a Windows case sensitivity problem. The compiler is case sensitive but the file system is not; or vice-versa. Such that you #include "shared/stdafx.h" when you should #include "Shared/StdAfx.h".

于 2013-04-27T23:14:43.483 回答
0

这很可能是因为之前的 C1189 错误,请参见此处

于 2013-04-28T09:10:17.487 回答
0

我知道这篇文章很老了,但它只是发生在我身上。

INCLUDEPATH += $$PWD

成功了。不要忘记做 qmake 然后构建所有。

一切顺利!

于 2018-01-30T07:41:23.247 回答