Sorry, I don't understand what you try to accomplish. Are you trying to document how your library has to be used by a client program? In this case, I've seen instructions like:
"... place an include directive to <cool_library.h> in your program"
"... place an include directive to <cool_library.h> before the include directive for <not_so_cool.h>"
If you are looking for something else, try to explain more.
It is still not clear what you mean by "the process". There is no process as such, you just need to ensure that the compiler can find all declarations and/or definitions of any functions that you are trying to use. Either within your source file or in an associated header.
The source code may be using definitions of classes/functions etc in an external library. The header file provides this information so the compiler can create a reference in the object code. Such references will then be used by the linker to fix the links to a library or other object code module. For example given the followin directory structure:
you might have:
// Library.h the defintions of the library, in the LIB subdirectory
void Foo(char* name);
// Library.c the implementation of the library, in the LIB subdirectory
void Foo(char* name)
printf("Hello, World! A message from %s\n", name);
//Implementor.cpp the program that will use the library, in the CLIENT subdirectory
#include"../LIB/Library.h"int main(int argc, char** argv)
The build process gets the #include of the library but fails to find the
first "#include in the library header file.
I am a little confused by some of your terminology, and also it is unclear which system you are using for the build. So a few possible ideas:
1. If this is using Visual Studio on Windows, you can add the locations of include directories to the Project settings. The compiler will search all such locations for include files.
2. If you are using a Makefile then add the include locations to the CPPFLAGS macro in the form "-I <include location>".
3. If the location of one of the headers is relative to the current directory then you can add the details to the #include statement thus:
4. If it is something else then please provide the details.
I am using Linux and QtCreator (IDE?)
One of the "features" of QTCreator is to manage several applications - they call it "projects" .
These projects are independent from each other, they only appear together in SUBDIRS tree.
Sort of nice management tool.
I can build a library using QtCreator and "add it " to the project. Works as expected.
I can add a standard Qt project to my SUBDIRS tree and change plain .cpp project to static library. No problem there.
I can make a reference - using #include - to the library, same as I did when "including" the real library.
The compiler "access" the library file - no issue.
The problem is - the library include file has / contains a slew of another includes and compiler fails to find the first one and build process is finished...
In my interpretation
since when I build the library and there is no issue with the includes
my usage of the library "Includes" is on different level - hence I am missing another
The directive should be in my source code , not in the library.
I prefer to solve this in C code , but I do have an option to add it to "make".
"Make" has sort of "includes" added by building the library, but they are for linker.
I have never used QTCreator so cannot offer any proper advice I am afraid. But from what you are saying you need to adjust some #include statements so that the compiler can find other files. And since we do not know the structure of your project or the content of the includes, it is difficult to guess what may be the actual change that is required.
You have a good point - the Qt "projects management" structure looks very suspicious.
The "projects" work as expected - individually.
But the "include" do not "line up" when projects are used as "LIB CLIENT"
/media/qe/TSET_QT_LABEL/QT_6/QT6_PRO/CAT/SUB_PRO/EXAMPLES_COPY/QT_5/Examples/Qt-6.2.0/bluetooth/btscanner_source/device.h:56:10: fatal error: qbluetoothlocaldevice.h: No such file or directory
56 | #include <qbluetoothlocaldevice.h>
There are two possibilities here:
1. Wherever this header file is located, it is not within any of the paths in the compiler's search list.
2. It is actually a local header file but has not been designated as such; try replacing the angle brackets by double quotes:
1. Replacing one description with another is hardly a solution.
2. Suggesting replacing <> with "" ? No comments.
I have compiler output from both "projects" and looking a place
where / how the includes do not align.
I did explain earlier that I have never used QTCreator. I was trying what I know to be the normal rules in all the systems I have ever worked with. Both of my suggestions are the natural ones to try in such a situation. The fact that QTCreator uses some special system of its own is something I was totally unaware of, but assumed that you were.
Another coder found the problem for me.
QT uses a component called "module"
My library has the correct module implemented and that why it work as standalone "project".
My client program DID NOT have the module implemented and that why the "include" chain was broken.
He found the problem analyzing the compiler out[put .
Thanks to everybody who contributed, this is how forum should work.