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. missing path to "include"
Qt 6.11 is out! See what's new in the release blog

missing path to "include"

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 913 Views 2 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.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on last edited by Chris Kawa
    #1

    I have "added existing file " device.h and project shows it correctly, however, simple #include "device.h" give an error - file cannot be found.

    I am getting two indicators of an error
    "no such file in directory"form complier
    and
    no "device.h" from intelisense "help"

    Do I have to add path to the "device.h" file in C code also and where ?

    Normally it could be added to GCC as "common include path ".

    Here is full path in project - which is correct

    HEADERS  += mainwindow.h \
        ../../../../../DEV_COPY_LABEL/Qt/Qt_TEST/GIT_Bluetooth/bluetooth/btscanner/device.h
    

    PS the "continue on next line symbol \ " is missing in the post after mainwindow.h

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by Chris Kawa
      #2

      PS the "continue on next line symbol \ " is missing in the post after mainwindow.h

      I fixed that for you. Forum uses Markdown. Place code snippets between ``` otherwise \ is treated as an escape character.

      The path you added looks odd. Is it correct? It should be relative to your .pro file. If the device.h is placed in the same directory as your .pro file then all you need is

      HEADERS  += mainwindow.h \
                  device.h
      

      Anyway, this only adds file to the project. It does not add its directory to include paths, so when you #include it it still has to have the whole path relative to the file you're including it from (or the project root). If you want to use just the file name in includes you need to add the path it is in to the INCLUDEPATH variable in your .pro file. This translates to the the -I option in gcc.

      1 Reply Last reply
      1
      • A Offline
        A Offline
        Anonymous_Banned275
        wrote on last edited by
        #3

        After my post I did use full path and complier is happy.

        Why moving the header file to local folder ?
        Is Qt allergic to standard ways?
        Apparently project is at least partially allergic.

        There must be something else I am missing which is causing this

        The actual file is from Qt downloaded examples and I am planning to reuse it in few projects.

        Chris KawaC 1 Reply Last reply
        0
        • A Anonymous_Banned275

          After my post I did use full path and complier is happy.

          Why moving the header file to local folder ?
          Is Qt allergic to standard ways?
          Apparently project is at least partially allergic.

          There must be something else I am missing which is causing this

          The actual file is from Qt downloaded examples and I am planning to reuse it in few projects.

          Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by Chris Kawa
          #4

          Why moving the header file to local folder ?

          Sorry, I didn't say you should move anything. I wrongly assumed this was a file of your project. If it's not then that's fine. You don't have to move anything.

          Is Qt allergic to standard ways?

          What do you mean by that? The only Qt part in this process is usage of qmake and all it does is pass whatever you give it to the compiler. Can you be more specific what is non-standard here and what standard do you mean?

          There must be something else I am missing which is causing this

          Sorry, I'm lost. Which is causing what? If you include one file from the other you have to pass either full or relative path between them. If you want to use just a file name in include you have to pass an include path for that file directly to the compiler (which is done via INCLUDEPATH in qmake). There's nothing Qt specific about this. This is how C++ compilers work.

          1 Reply Last reply
          1

          • Login

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