Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to find include directive path?

How to find include directive path?

Scheduled Pinned Locked Moved C / C++ / MFC
questiontutorial
11 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    I Successfully converted standard Qt project to a library. I build a library "lxxx". I "added"the library to a Qt SUBDIR project - same as another project under SUBFIR management. Builds fine. When I try to use the library, by adding ONE if the library include file It "links" fine to the library include file BUT fails to locate / link with another include in the "source " file. I am not sure about terminology but basically in header file of code I want to be linked to a library I add # inlcude a header file / source of the library to be used. The build process gets the #include of the library but fails to find the first "#include in the library header file. Since I build the library using SAME include scheme OUTSIDE SUBDIRS project I suspect I need to add another path . How do I determine what is the actual #include directive path so I can correct it? 'If my post does not make sense , please ask for clarification before responding.

    L 2 Replies Last reply
    0
    • L Lost User

      I Successfully converted standard Qt project to a library. I build a library "lxxx". I "added"the library to a Qt SUBDIR project - same as another project under SUBFIR management. Builds fine. When I try to use the library, by adding ONE if the library include file It "links" fine to the library include file BUT fails to locate / link with another include in the "source " file. I am not sure about terminology but basically in header file of code I want to be linked to a library I add # inlcude a header file / source of the library to be used. The build process gets the #include of the library but fails to find the first "#include in the library header file. Since I build the library using SAME include scheme OUTSIDE SUBDIRS project I suspect I need to add another path . How do I determine what is the actual #include directive path so I can correct it? 'If my post does not make sense , please ask for clarification before responding.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Member 14968771 wrote:

      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:

      #include "subdir\library.h"

      4. If it is something else then please provide the details.

      L 1 Reply Last reply
      0
      • L Lost User

        Member 14968771 wrote:

        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:

        #include "subdir\library.h"

        4. If it is something else then please provide the details.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        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 include directive. 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.

        L 1 Reply Last reply
        0
        • L Lost User

          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 include directive. 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.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          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.

          L 1 Reply Last reply
          0
          • L Lost User

            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.

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            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"

            L 1 Reply Last reply
            0
            • L Lost User

              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"

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Maybe you would get a better answer at Home | Qt Forum[^].

              L 1 Reply Last reply
              0
              • L Lost User

                Maybe you would get a better answer at Home | Qt Forum[^].

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                How about if I be brave and post this on both forum? I am not sure the answer is in the compiler output , but it is a real place to check stuff. AND I DO APOLOGIZE FOR TAKING SO MUCH MEMORY

                11:05:54: Running steps for project TEST_SUB...
                11:05:54: Starting: "/usr/bin/make" clean -j4
                rm -f moc_predefs.h
                rm -f moc_mainwindow.cpp
                rm -f ui_mainwindow.h
                rm -f main.o mainwindow.o moc_mainwindow.o
                rm -f *~ core *.core
                11:05:54: The process "/usr/bin/make" exited normally.
                11:05:55: Starting: "/home/qe/Qt_5/6.2.0/gcc_64/bin/qmake" /media/qe/TSET_QT_LABEL/TEST_FOLDER/TEST_SUB_MAIN/TEST_SUB_PROJECT/TEST_SUB/FIRST_SUB/FIRST_SUB.pro -spec linux-g++ CONFIG+=debug CONFIG+=qml_debug
                11:05:55: The process "/home/qe/Qt_5/6.2.0/gcc_64/bin/qmake" exited normally.
                11:05:55: Starting: "/usr/bin/make" -f /media/qe/TSET_QT_LABEL/TEST_FOLDER/TEST_SUB_MAIN/TEST_SUB_PROJECT/build-TEST_SUB-Desktop_Qt_6_2_0_GCC_64bit-Debug/FIRST_SUB/Makefile qmake_all
                make: Nothing to be done for 'qmake_all'.
                11:05:55: The process "/usr/bin/make" exited normally.
                11:05:55: Starting: "/usr/bin/make" -j4
                /home/qe/Qt_5/6.2.0/gcc_64/libexec/uic ../../TEST_SUB/FIRST_SUB/mainwindow.ui -o ui_mainwindow.h
                g++ -c -pipe -g -std=gnu++1z -Wall -Wextra -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../TEST_SUB/FIRST_SUB -I. -I../../TEST_SUB/TEST_PROJECT -I../../TEST_SUB/TEST_LIBRARY -I/media/qe/TSET_QT_LABEL/QT_6/QT6_PRO/CAT/SUB_PRO/EXAMPLES_COPY/QT_5/Examples/Qt-6.2.0/bluetooth/btscanner_source -IQTDIR -I/home/qe/Qt_5/6.2.0/gcc_64/include -I/home/qe/Qt_5/6.2.0/gcc_64/include/QtWidgets -I/home/qe/Qt_5/6.2.0/gcc_64/include/QtGui -I/home/qe/Qt_5/6.2.0/gcc_64/include/QtCore -I. -I. -I/home/qe/Qt_5/6.2.0/gcc_64/mkspecs/linux-g++ -o main.o ../../TEST_SUB/FIRST_SUB/main.cpp
                g++ -c -pipe -g -std=gnu++1z -Wall -Wextra -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../TEST_SUB/FIRST_SUB -I. -I../../TEST_SUB/TEST_PROJECT -I../../TEST_SUB/TEST_LIBRARY -I/media/qe/TSET_QT_LABEL/QT_6/QT6_PRO/CAT/SUB_PRO/EXAMPLES_COPY/QT_5/Examples/Qt-6.2.0/bluetooth/btscanner_source -IQTDIR -I/home/qe/Qt_5/6.2.0/gcc_64/include -I/home/qe/Qt_5/6.2.0/gcc_64/include/QtWidgets -I/home/qe/Qt_5/6.2.0/gcc_64/include/QtGui -I/home/qe/Qt_5/6.2.0/gcc_64/include/QtCore -I. -I. -I/home/qe/Qt_5/6.2.0/gcc_64/mkspecs/linux-g++ -o mainwindow.o ../../TEST_SUB/FIRST_SUB/mainwindow.cpp
                g++ -pipe -g -std=gnu++1z -Wall -Wextra -dM -E -o moc_predefs.h /home/qe/Qt_5/6.2.0/gcc_64/mkspecs/features/data/dummy.cpp
                /home/qe/Qt_

                L 1 Reply Last reply
                0
                • L Lost User

                  How about if I be brave and post this on both forum? I am not sure the answer is in the compiler output , but it is a real place to check stuff. AND I DO APOLOGIZE FOR TAKING SO MUCH MEMORY

                  11:05:54: Running steps for project TEST_SUB...
                  11:05:54: Starting: "/usr/bin/make" clean -j4
                  rm -f moc_predefs.h
                  rm -f moc_mainwindow.cpp
                  rm -f ui_mainwindow.h
                  rm -f main.o mainwindow.o moc_mainwindow.o
                  rm -f *~ core *.core
                  11:05:54: The process "/usr/bin/make" exited normally.
                  11:05:55: Starting: "/home/qe/Qt_5/6.2.0/gcc_64/bin/qmake" /media/qe/TSET_QT_LABEL/TEST_FOLDER/TEST_SUB_MAIN/TEST_SUB_PROJECT/TEST_SUB/FIRST_SUB/FIRST_SUB.pro -spec linux-g++ CONFIG+=debug CONFIG+=qml_debug
                  11:05:55: The process "/home/qe/Qt_5/6.2.0/gcc_64/bin/qmake" exited normally.
                  11:05:55: Starting: "/usr/bin/make" -f /media/qe/TSET_QT_LABEL/TEST_FOLDER/TEST_SUB_MAIN/TEST_SUB_PROJECT/build-TEST_SUB-Desktop_Qt_6_2_0_GCC_64bit-Debug/FIRST_SUB/Makefile qmake_all
                  make: Nothing to be done for 'qmake_all'.
                  11:05:55: The process "/usr/bin/make" exited normally.
                  11:05:55: Starting: "/usr/bin/make" -j4
                  /home/qe/Qt_5/6.2.0/gcc_64/libexec/uic ../../TEST_SUB/FIRST_SUB/mainwindow.ui -o ui_mainwindow.h
                  g++ -c -pipe -g -std=gnu++1z -Wall -Wextra -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../TEST_SUB/FIRST_SUB -I. -I../../TEST_SUB/TEST_PROJECT -I../../TEST_SUB/TEST_LIBRARY -I/media/qe/TSET_QT_LABEL/QT_6/QT6_PRO/CAT/SUB_PRO/EXAMPLES_COPY/QT_5/Examples/Qt-6.2.0/bluetooth/btscanner_source -IQTDIR -I/home/qe/Qt_5/6.2.0/gcc_64/include -I/home/qe/Qt_5/6.2.0/gcc_64/include/QtWidgets -I/home/qe/Qt_5/6.2.0/gcc_64/include/QtGui -I/home/qe/Qt_5/6.2.0/gcc_64/include/QtCore -I. -I. -I/home/qe/Qt_5/6.2.0/gcc_64/mkspecs/linux-g++ -o main.o ../../TEST_SUB/FIRST_SUB/main.cpp
                  g++ -c -pipe -g -std=gnu++1z -Wall -Wextra -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../TEST_SUB/FIRST_SUB -I. -I../../TEST_SUB/TEST_PROJECT -I../../TEST_SUB/TEST_LIBRARY -I/media/qe/TSET_QT_LABEL/QT_6/QT6_PRO/CAT/SUB_PRO/EXAMPLES_COPY/QT_5/Examples/Qt-6.2.0/bluetooth/btscanner_source -IQTDIR -I/home/qe/Qt_5/6.2.0/gcc_64/include -I/home/qe/Qt_5/6.2.0/gcc_64/include/QtWidgets -I/home/qe/Qt_5/6.2.0/gcc_64/include/QtGui -I/home/qe/Qt_5/6.2.0/gcc_64/include/QtCore -I. -I. -I/home/qe/Qt_5/6.2.0/gcc_64/mkspecs/linux-g++ -o mainwindow.o ../../TEST_SUB/FIRST_SUB/mainwindow.cpp
                  g++ -pipe -g -std=gnu++1z -Wall -Wextra -dM -E -o moc_predefs.h /home/qe/Qt_5/6.2.0/gcc_64/mkspecs/features/data/dummy.cpp
                  /home/qe/Qt_

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  /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

                  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:

                  #include "qbluetoothlocaldevice.h"

                  L 1 Reply Last reply
                  0
                  • L Lost User

                    /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

                    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:

                    #include "qbluetoothlocaldevice.h"

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #9

                    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.

                    L 1 Reply Last reply
                    0
                    • L Lost User

                      I Successfully converted standard Qt project to a library. I build a library "lxxx". I "added"the library to a Qt SUBDIR project - same as another project under SUBFIR management. Builds fine. When I try to use the library, by adding ONE if the library include file It "links" fine to the library include file BUT fails to locate / link with another include in the "source " file. I am not sure about terminology but basically in header file of code I want to be linked to a library I add # inlcude a header file / source of the library to be used. The build process gets the #include of the library but fails to find the first "#include in the library header file. Since I build the library using SAME include scheme OUTSIDE SUBDIRS project I suspect I need to add another path . How do I determine what is the actual #include directive path so I can correct it? 'If my post does not make sense , please ask for clarification before responding.

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #10

                      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. Cheers

                      1 Reply Last reply
                      0
                      • L Lost User

                        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.

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #11

                        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.

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups