Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Unsolved Deep in the folder

    General and Desktop
    4
    9
    954
    Loading More Posts
    • 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
      Papa last edited by

      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 Reply Quote 0
      • ?
        A Former User last edited by

        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 Reply Quote 0
        • SGaist
          SGaist Lifetime Qt Champion last edited by

          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 Reply Quote 0
          • P
            Papa last edited by

            @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 Reply Quote 0
            • ?
              A Former User last edited by

              @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 Reply Quote 0
              • P
                Papa last edited by

                tried it, but it did not work :(

                1 Reply Last reply Reply Quote 0
                • ?
                  A Former User last edited by

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

                  1 Reply Last reply Reply Quote 0
                  • P
                    Papa last edited by

                    Nope, it does not work.

                    1 Reply Last reply Reply Quote 0
                    • jsulm
                      jsulm Lifetime Qt Champion last edited by

                      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 Reply Quote 0
                      • First post
                        Last post