Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Deep in the folder
QtWS25 Last Chance

Deep in the folder

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 4 Posters 1.3k Views
  • 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.
  • P Offline
    P Offline
    Papa
    wrote on last edited by
    #1

    Deep in the directory tree are my personal library-files and instead of writing the whole directory tree i.e.
    #include "C:\Dev\persoal\list\of\my\library\that\only\I\can\use\in\my\programs\myfile.h"
    I would rather just write:
    #include "myfile.h"

    Is there a way to tell Qt Creator [latest version, just downloaded] to add a new or another search directory?

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Hi! Just add

      INCLUDEPATH += C:\Dev\persoal\list\of\my\library\that\only\I\can\use\in\my\programs
      

      to your *.pro file.

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        To add to @Wieland, since you are using Qt, you should use forward slashes in your paths (the unix notation) that will avoid having to escape every backslashes.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • P Offline
          P Offline
          Papa
          wrote on last edited by
          #4

          @Wieland said:

          INCLUDEPATH += C:\Dev\persoal\list\of\my\library\that\only\I\can\use\in\my\programs

          Under the [INCLUDEPATH] is a file named i.e. "thunder.hpp". So the directory tree looks like this
          [INCLUDEPATH]
          | ----- thunder.hpp {FILE}
          |----->Message {DIRECTORY}
          |-----message.hpp {FILE}
          |------message.cpp {FILE}

          Now, in my main.c, created by Qt Creator, I have include these files like this:
          #include "thunder.hpp"
          #include "Message/message.hpp"

          but this gives me an error saying:
          C:....\main.cpp:8: error: C1083: Cannot open include file: 'thunder.hpp': No such file or directory.

          But if I modify the code in main.c to look like this
          #include "C:\Dev\persoal\list\of\my\library\that\only\I\can\use\in\my\programs\thumder.hpp"
          then the program compiles.

          It seems to me that setting up the INCLUDEPATH variable in the .pro file fails to read the files under the INCLUDEPATH and it only reads the sub-directories under it. Is this the right assumption, or is there something wrong with my code?

          How can I solve this problem?

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            @Papa said:

            #include "thunder.hpp"
            #include "Message/message.hpp"

            Try to replace this by:

            #include <thunder.hpp>
            #include <Message/message.hpp>
            
            1 Reply Last reply
            0
            • P Offline
              P Offline
              Papa
              wrote on last edited by
              #6

              tried it, but it did not work :(

              1 Reply Last reply
              0
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #7

                Just tested it. Works for me. Clean the project and re-run qmake.

                1 Reply Last reply
                0
                • P Offline
                  P Offline
                  Papa
                  wrote on last edited by
                  #8

                  Nope, it does not work.

                  1 Reply Last reply
                  0
                  • jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    Did you changed the backslashes to forward-slashes as SGaist suggested?
                    So instead of C:\Dev\persoal\list\of\my\library\that\only\I\can\use\in\my\programs
                    you should use C:/Dev/persoal/list/of/my/library/that/only/I/can/use/in/my/programs
                    After this change delete the build directory and completely rebuild your project.

                    Is the name of the header file really thunder.hpp? If Message/message.hpp is working then thunder.hpp should work as well.

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved