INCLUDEPATH ??
-
Here is the "INCLUDEPATH" as a result of "add library" to a project in SUB_DIRS .
The PWD seem to be normal path to a file , however I do not know why "/,,/,,/,,/../" gets inserted.INCLUDEPATH += $$PWD/../../../../PROJECTS/CAT_FT857_BLUETOOTH/CAT_FT857_BLUETOOTH_MAIN_PROJECT/CAT_DEBUG_LIB
Here is my debug output
Project MESSAGE: stadard application template app btscanner.pro Project MESSAGE: btscanner inlcude path for CAT_Libarary/CAT_Libraray Project MESSAGE: /home/qt/Qt/Examples/Qt-5.15.2/bluetooth/btscanner/../../../../PROJECTS/CAT_FT857_BLUETOOTH/CAT_FT857_BLUETOOTH_MAIN_PROJECT/CAT_Library/CAT_Library Project MESSAGE: btscanner inlcude path for CAT_DEBUG_LIB Project MESSAGE: /home/qt/Qt/Examples/Qt-5.15.2/bluetooth/btscanner/../../../../PROJECTS/CAT_FT857_BLUETOOTH/CAT_FT857_BLUETOOTH_MAIN_PROJECT/CAT_Library/CAT_Library /home/qt/Qt/Examples/Qt-5.15.2/bluetooth/btscanner/../../../../PROJECTS/CAT_FT857_BLUETOOTH/CAT_FT857_BLUETOOTH_MAIN_PROJECT/CAT_DEBUG_LIB
When I implement include , howering above the code the entire path plus the header looks normal / correct no "../.../ ../ " , but complier / linker cannot find it.
#include "CAT_DEBUG_LIB_global.h" looks OK
I am not sure what is the problem - added /../../../ directive to path or multiple INCLUDEPATH. Help would be appreciated.
-
@AnneRanch said in INCLUDEPATH ??:
I do not know why "/,,/,,/,,/../" gets inserted.
../
means "go up one directory level". So, the following 2 paths point to the same location:/home/qt/Qt/Examples/Qt-5.15.2/
/home/qt/Qt/Tools/../Examples/Qt-5.15.2/
complier / linker cannot find it.
Please show the full error message from the compiler/linker.
P.S. This question is about Qt configuration, not C++. Post moved from the "C++ Gurus" subforum to the "General and Desktop" subforum.
-
/home/qt/Qt/Examples/Qt-5.15.2/bluetooth/btscanner/device.h:54: error: CAT_DEBUG_LIB_global.h: No such file or directory
In file included from ./mdi_common_header.h:23,
from mainwindow.h:83,
from main.cpp:68:
/home/qt/Qt/Examples/Qt-5.15.2/bluetooth/btscanner/device.h:54:10: fatal error: CAT_DEBUG_LIB_global.h: No such file or directory
54 | #include "CAT_DEBUG_LIB_global.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~PS.
Please READ the post.
I am not asking what "../ " does . -
@AnneRanch said in INCLUDEPATH ??:
CAT_DEBUG_LIB_global.h: No such file or directory
OK. Next:
- Show us the full path to
CAT_DEBUG_LIB_global.h
- Shows us the full .pro file that contains the INCLUDEPATH
Please READ the post.
I am not asking what "../ " does .Please THINK. If you start from
/home/qt/Qt/Examples/Qt-5.15.2/bluetooth/btscanner/
, how do you write a relative path to get to/home/qt/Qt/PROJECTS/CAT_FT857_BLUETOOTH/CAT_FT857_BLUETOOTH_MAIN_PROJECT/CAT_DEBUG_LIB
?Once you have thought about it, and combine that with knowledge of what
../
does, then you should see why../../../../
gets inserted. And you should also see that inserting../../../../
is not the problem. - Show us the full path to
-
It appears that project .pro INCLUDEPATH entry AKA path to library include header HAS no bearing on USAGE of the library. .
In basic - when a shared library is used in code the .cpp file has to have a means to access such library source - AKA library header is used.
I assumed that project INCLUDEPATH - added by "add libray" provides for such path to the include header.
In the basic way it does - since compiler / linker finds the header without any issues. .
But the actual access /usage of the library gives "undefined symbol"
UNTIL
full path to the #include header is provided in .cpp file!I would welcome any opposing views or reasonable explanation why this is working only "half way " - OK as "header is present" but "nothing is defined ".
Otherwise I like to consider this closed - with no real solution.
-
@AnneRanch
you are using "Add Library" feature to add the library/link to the project.
Added library path using "Internal Library" option right?
Does btscanner library project and application required to use the library, do co exist in single build tree?I am not sure what is the problem - added /../../../ directive to path
Original btscanner example is having
#include "ui_device.h"
which is a uic generated header file.
Does this header file "CAT_DEBUG_LIB_global.h" do exists at the time of linking with the application ?
Does "CAT_DEBUG_LIB_global.h" exists in the location where device.h file is located?Because if library is built using "shadow build option" uic generated files will not be present in the directory where device.h file is located.
-
@AnneRanch said in INCLUDEPATH ??:
@JKSH PLEASE READ the original post.
It contains stuff relevant to the problem - no need for full .pro file
It stated HOW the INCLUDEPATH was created..Your original post is missing important information. The INCLUDEPATH is insufficient.
I would welcome any opposing views or reasonable explanation why this is working only "half way " - OK as "header is present" but "nothing is defined ".
Otherwise I like to consider this closed - with no real solution.Why? Because you didn't add the library correctly.
There IS a real solution: Fix your .pro files.
full path to the #include header is provided in .cpp file!
Never put the full path in the #include header. This is bad.
IMPORTANT: Your posts contain 2 separate issues:
- If
INCLUDEPATH +=
and/or#include
are wrong, you get a Compiler issue like "error: CAT_DEBUG_LIB_global.h: No such file or directory" - If
LIBS +=
is wrong, you get a Linker issue like "undefined symbols"
If you provide your full .pro files, we can easily check these for you.
- If
-
@nagesh
At present the intelisensnse guides me to add "#include" header to the .cpp file and such add without full path passes by compiler / linker.Implementing the Qt added library gives "undefined symbols".
Using the same verbatim as intelisense - specifying full path plus the header removes "undefined symbols" .
Therefore
Qt "add library" does not add the required header - it cannot. The library INCLUDEPATH is added to specific project , not to specific .cpp - and when the header is added using full path to the .cpp the project runs.At this point I am not interested in finding out why this is happening.
PS I do not recall specifying 'shadow library" .
-
Does this header file "CAT_DEBUG_LIB_global.h" do exists at the time of linking with the application ?
Yes, the file is generated by "add library" - its function is to "switch" from importing / exporting the library and it works as expected.Does "CAT_DEBUG_LIB_global.h" exists in the location where device.h file is located?
No, per above it is part of the code generated by "add library" and resides in the generated library source code.The actual generated header is cat_debug_lib.h
which is manually included in the .cpp source as referenceAnd it is added as full path
#include </home/qt/Qt/PROJECTS/CAT_FT857_BLUETOOTH/CAT_FT857_BLUETOOTH_MAIN_PROJECT/CAT_DEBUG_LIB/cat_debug_lib.h>
Both library includes are "linked to each other - using another include ( add library generated ) scheme " in the library source code so there is no need to "include" both in .cpp file.
That all works as expected - ONLY when full path is specified in .cpp.