Unsolved missing path to "include"
-
I have "added existing file " device.h and project shows it correctly, however, simple #include "device.h" give an error - file cannot be found.
I am getting two indicators of an error
"no such file in directory"form complier
and
no "device.h" from intelisense "help"Do I have to add path to the "device.h" file in C code also and where ?
Normally it could be added to GCC as "common include path ".
Here is full path in project - which is correct
HEADERS += mainwindow.h \ ../../../../../DEV_COPY_LABEL/Qt/Qt_TEST/GIT_Bluetooth/bluetooth/btscanner/device.h
PS the "continue on next line symbol \ " is missing in the post after mainwindow.h
-
PS the "continue on next line symbol \ " is missing in the post after mainwindow.h
I fixed that for you. Forum uses Markdown. Place code snippets between ``` otherwise \ is treated as an escape character.
The path you added looks odd. Is it correct? It should be relative to your .pro file. If the
device.h
is placed in the same directory as your .pro file then all you need isHEADERS += mainwindow.h \ device.h
Anyway, this only adds file to the project. It does not add its directory to include paths, so when you
#include
it it still has to have the whole path relative to the file you're including it from (or the project root). If you want to use just the file name in includes you need to add the path it is in to the INCLUDEPATH variable in your .pro file. This translates to the the-I
option in gcc. -
After my post I did use full path and complier is happy.
Why moving the header file to local folder ?
Is Qt allergic to standard ways?
Apparently project is at least partially allergic.There must be something else I am missing which is causing this
The actual file is from Qt downloaded examples and I am planning to reuse it in few projects.
-
Why moving the header file to local folder ?
Sorry, I didn't say you should move anything. I wrongly assumed this was a file of your project. If it's not then that's fine. You don't have to move anything.
Is Qt allergic to standard ways?
What do you mean by that? The only Qt part in this process is usage of qmake and all it does is pass whatever you give it to the compiler. Can you be more specific what is non-standard here and what standard do you mean?
There must be something else I am missing which is causing this
Sorry, I'm lost. Which is causing what? If you include one file from the other you have to pass either full or relative path between them. If you want to use just a file name in include you have to pass an include path for that file directly to the compiler (which is done via INCLUDEPATH in qmake). There's nothing Qt specific about this. This is how C++ compilers work.