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. cannot find file if the file is in another directory.
Forum Update on Monday, May 27th 2025

cannot find file if the file is in another directory.

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 4 Posters 2.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.
  • Q Offline
    Q Offline
    qtpi
    wrote on 23 Feb 2016, 10:23 last edited by
    #1

    folks, in my project some files are in another directory but not in the directory where main is. Weird enough, I successfully compiled it days ago, this morning I tried it again and it failed to compile. Qt creator says: "cannot find xxx.h, no such file".

    I've included all the head files with double quotation marks "", and all the files are in my project tree.

    any suggestion how to fix this?

    K 2 Replies Last reply 23 Feb 2016, 10:33
    0
    • Q qtpi
      23 Feb 2016, 10:23

      folks, in my project some files are in another directory but not in the directory where main is. Weird enough, I successfully compiled it days ago, this morning I tried it again and it failed to compile. Qt creator says: "cannot find xxx.h, no such file".

      I've included all the head files with double quotation marks "", and all the files are in my project tree.

      any suggestion how to fix this?

      K Offline
      K Offline
      koahnig
      wrote on 23 Feb 2016, 10:33 last edited by koahnig
      #2

      @qtpi said:

      cannot find xxx.h, no such file

      Is it a message from Qt creator or from the compiler?
      I guess the latter one.

      If your include statements are now in your source file:
      #include ""xxx.h""

      that is definitely wrong. You need duplicated quotation marks for string definitions, but not for ordinary code.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • Q qtpi
        23 Feb 2016, 10:23

        folks, in my project some files are in another directory but not in the directory where main is. Weird enough, I successfully compiled it days ago, this morning I tried it again and it failed to compile. Qt creator says: "cannot find xxx.h, no such file".

        I've included all the head files with double quotation marks "", and all the files are in my project tree.

        any suggestion how to fix this?

        K Offline
        K Offline
        koahnig
        wrote on 23 Feb 2016, 10:37 last edited by
        #3

        @qtpi
        include syntax1
        include syntax2

        Vote the answer(s) that helped you to solve your issue(s)

        Q 1 Reply Last reply 23 Feb 2016, 10:53
        0
        • K koahnig
          23 Feb 2016, 10:37

          @qtpi
          include syntax1
          include syntax2

          Q Offline
          Q Offline
          qtpi
          wrote on 23 Feb 2016, 10:53 last edited by
          #4

          @koahnig

          i understand what you mean. and i know the difference between "" and <>.

          but my question is do i need to always include a absolute path like c:/qt/file/xxx.h? simply "xxx.h" not gonna work?

          K 1 Reply Last reply 23 Feb 2016, 11:08
          0
          • K Offline
            K Offline
            kenchan
            wrote on 23 Feb 2016, 11:05 last edited by kenchan
            #5

            Can you see something like this in your pro file/

            SOURCES +=
            mydirectory/myfile.cpp \
            mydirectory/myotherfile.cpp

            if not edit it by hand or select your files into the project again.

            1 Reply Last reply
            0
            • Q qtpi
              23 Feb 2016, 10:53

              @koahnig

              i understand what you mean. and i know the difference between "" and <>.

              but my question is do i need to always include a absolute path like c:/qt/file/xxx.h? simply "xxx.h" not gonna work?

              K Offline
              K Offline
              kenchan
              wrote on 23 Feb 2016, 11:08 last edited by kenchan
              #6

              Then again for include paths you can use this

              INCLUDEPATH += myincludedirectory \
              myotherincludedirectory

              etc...

              Q 1 Reply Last reply 23 Feb 2016, 13:57
              0
              • S Offline
                S Offline
                stackprogramer
                wrote on 23 Feb 2016, 11:18 last edited by
                #7

                hi,you can click right >add existing files and add header and cpp files for classes.
                now you should add #inlcude <> files and directories.

                1 Reply Last reply
                0
                • K kenchan
                  23 Feb 2016, 11:08

                  Then again for include paths you can use this

                  INCLUDEPATH += myincludedirectory \
                  myotherincludedirectory

                  etc...

                  Q Offline
                  Q Offline
                  qtpi
                  wrote on 23 Feb 2016, 13:57 last edited by
                  #8

                  @kenchan that looks interesting. i solved the problem by adding a absolute path.
                  but i'm gonna give it a try with your idea. it seems to be actually a better way.

                  1 Reply Last reply
                  0

                  1/8

                  23 Feb 2016, 10:23

                  • Login

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