I have the below in my .pro file and I have files that #include "headerhere".
For example: #include "StdAfx.h"
. However I'm getting an
error Cannot open include file: 'StdAfx.h': No such file or directory.
I get the same error whether I use #include "StdAfx.h"
or #include "Shared/StdAfx.h"
. This is extremely frustrating and I can't do any actual work unless Qt starts recognizing my headers. I've found online no solution for this. What is going on?
.pro file has:
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
EDIT: why I am getting downvotes? This is a legitimate problem I'm having
Even if it does not, it will certainly waste time. This construct is commonly known as a wrapper #ifndef. When the header is included again, the conditional will be false, because FILE_FOO_SEEN is defined. The preprocessor will skip over the entire contents of the file, and the compiler will not see it twice.
Yes, this will work. Note, however, that if you include a lot of headers in this file and don't need all of them in each of your source files, it will likely increase your compilation time.
You make the declarations in a header file, then use the #include directive in every . cpp file or other header file that requires that declaration. The #include directive inserts a copy of the header file directly into the . cpp file prior to compilation.
Double-click the . pro file in the Finder/File Explorer. In the Qt Creator application, choose menu File->Open File or Project, navigate to the project folder and choose the . pro file to open.
I had the same problem as well. The reason was that I use two computers in parallel and the makefile tried to find files at paths as they are set on the previous one. But everything seemed to be fine - as in your case, tooltip when hovering over the include showed me the correct path, also F2 (follow symbol under cursor) navigated me to the correct header.
I thought qmake is re-maked each time I change something in the .pro file, but obviously not.
Just run Build->qmake, it should fix it.
You need to update the qmake file.
Build-> Run qmake
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With