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. File not found error for unincluded headers
Forum Updated to NodeBB v4.3 + New Features

File not found error for unincluded headers

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 383 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.
  • A Offline
    A Offline
    ablan
    wrote on last edited by
    #1

    I have a c++ driver header file which have the lines
    #ifndef Q_OS_WIN
    #include <linux/i2c.h>
    #include <linux/i2c-dev.h>
    #endif
    When I try to compile this on Windows, it fails to compile and gives file not found error for the i2c.h and i2c-dev.h. But they are not supposed to be included at all since the #ifndef statement should have excluded them. I do not get what is causing this error.

    jsulmJ 1 Reply Last reply
    0
    • A ablan

      I have a c++ driver header file which have the lines
      #ifndef Q_OS_WIN
      #include <linux/i2c.h>
      #include <linux/i2c-dev.h>
      #endif
      When I try to compile this on Windows, it fails to compile and gives file not found error for the i2c.h and i2c-dev.h. But they are not supposed to be included at all since the #ifndef statement should have excluded them. I do not get what is causing this error.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @ablan said in File not found error for unincluded headers:

      Q_OS_WIN

      Did you include QtGlobal header file where you're using Q_OS_WIN?

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

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

        Hi,

        Beside the good point made by @jsulm, to avoid such a case, you should rather use

        #ifdef Q_OS_LINUX
        

        as there are other OSs that Qt supports that will not have these includes.

        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
        1
        • A Offline
          A Offline
          ablan
          wrote on last edited by
          #4

          Thanks for the replies, I included QtGlobal, but it is still giving me the same file not found compilation error.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            ablan
            wrote on last edited by
            #5

            I found solution. The header file was not included in the HEADERS of .pro file. I just add it to the HEADERS and the compilation error disappeared.

            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