Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. [SOLVED] Wrong header file included in project
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Wrong header file included in project

Scheduled Pinned Locked Moved Qt Creator and other tools
3 Posts 2 Posters 2.1k 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.
  • D Offline
    D Offline
    der.ule
    wrote on last edited by
    #1

    Hello,

    I'm having a problem with my project file in QtCreator and haven't been able to figure it out.

    I have a directory with a project, that uses a hardware device and its libraries; as I don't have always the hardware available, I've make a project with some dummy object in a different directory to test my code. I have used this solution before without a problem, but for some reason is not working in this case.

    My directories look like this:
    @DiagnosticBox <--- This directory is used when the hardware is present
    -labjack.h and labjack.cpp

    • adminpanel.h and adminpanel.cpp
    • connectiondialog.h and connectiondialog.cpp
    • labjackUD.h <---- This is the library header of the hardware

    testDiagnosticBox
    -labjack.h and labjack.cpp <---- This class is a dummy class, with no hardware dependencies@

    My .pro file is:

    @
    QT += core gui network

    TARGET = testDiagnosticBox
    INCLUDEPATH += ./DiagnosticBox/

    TEMPLATE = app

    SOURCES += main.cpp
    mainwindow.cpp
    ../DiagnosticBox/adminpanel.cpp
    ../DiagnosticBox/connectiondialog.cpp
    labjack.cpp \

    HEADERS += mainwindow.h
    ../DiagnosticBox/adminpanel.h
    ../DiagnosticBox/connectiondialog.h
    labjack.h \

    FORMS += mainwindow.ui
    labjack.ui
    ../DiagnosticBox/adminpanel.ui
    ../DiagnosticBox/connectiondialog.ui
    @

    The problem is that, when I try to compile the project testDiagnosticBox I receive the error

    @...\DiagnosticBox\labjack.h:5: error: LabJackUD.h: No such file or directory@

    Meaning that even though is not listed in my SOURCES or HEADERS, qmake is using the file in DiagnosticBox and not the one in testDiagnosticBox, is that the expected behavior ? How can I avoid that ? Should it not be taking the file in testEncoderBox ?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      The labjack.h file is included in some other files of your project.
      I guess it is included without directory name like @#include "labjack.h"@

      And if that file with "#include "labjack.h" is located in DiagnosticBox then compiler takes labjack.h from the same directory.
      The variables SOURCES and HEADERS are for qmake only a compiler reads included files according its own options and that options are defined by INCLUDEPATH.
      To avoid it you need to specify different INCLUDEPATH for your test library.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        der.ule
        wrote on last edited by
        #3

        Thanks a lot andreyc, I was assuming that HEADERS and SOURCES where somehow also used by the compiler.

        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