Page 1 of 2 12 LastLast
Results 1 to 20 of 24

Thread: INCLUDEPATH how it works ?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default INCLUDEPATH how it works ?

    If I have a correct path at INCLUDEPATH, why is the reason because I have undefined reference errors for certain h files located at this path ? It is solved if I add the file 'by hand'.
    And... I imagine that I could have different versions of files, and I only would have to change the INCLUDEPATH to use one or other, but I think it does not going to work ...
    Any explanation ? Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: INCLUDEPATH how it works ?

    "h" files have nothing to do with unresolved reference errors.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Sep 2010
    Posts
    45
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: INCLUDEPATH how it works ?

    Post your .pro file in the forum.
    It seems to be an editing error.

    Quote Originally Posted by wysota View Post
    "h" files have nothing to do with unresolved reference errors.
    Ops. you have right.


    ------------
    Probably you have forgotten some to edit the LIBS variable or to add some dll or obj.
    http://doc.trolltech.com/4.7/qmake-v...ence.html#libs
    Last edited by bred; 27th October 2010 at 19:05.

  4. #4
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: INCLUDEPATH how it works ?

    This is the pro file :

    Qt Code:
    1. QT += core gui
    2.  
    3. TEMPLATE = app
    4. CONFIG += qt debug_and_release
    5.  
    6.  
    7. TARGET = gui_plu
    8.  
    9.  
    10. INCLUDEPATH += ../AnalogWidgets/analogwidgets/analogwidgets \
    11. ../AnalogWidgets/analogwidgets/code
    12.  
    13. HEADERS += form.h \
    14. ../AnalogWidgets/analogwidgets/analogwidgets/wallclock.h \
    15. ../AnalogWidgets/analogwidgets/analogwidgets/widgetwithbackground.h \ (<<< the line I delete ... )
    16. ../AnalogWidgets/analogwidgets/analogwidgets/led.h \
    17. ../AnalogWidgets/analogwidgets/plugins/led_plugin.h \
    18. ../AnalogWidgets/analogwidgets/plugins/wallclock_plugin.h
    19.  
    20. SOURCES += form.cpp \
    21. main.cpp \
    22. ../AnalogWidgets/analogwidgets/code/wallclock.cpp \
    23. ../AnalogWidgets/analogwidgets/code/widgetwithbackground.cpp \
    24. ../AnalogWidgets/analogwidgets/code/led.cpp \
    25. ../AnalogWidgets/analogwidgets/plugins/wallclock_plugin.cpp \
    26. ../AnalogWidgets/analogwidgets/plugins/led_plugin.cpp
    27.  
    28. FORMS += \
    29. form.ui
    To copy to clipboard, switch view to plain text mode 


    If I delete ../AnalogWidgets/analogwidgets/analogwidgets/widgetwithbackground.h \ i have :

    ../AnalogWidgets/analogwidgets/code/widgetwithbackground.cpp:26: undefined reference to `vtable for WidgetWithBackground'
    ../AnalogWidgets/analogwidgets/code/widgetwithbackground.cpp:26: undefined reference to `vtable for WidgetWithBackground'
    ../AnalogWidgets/analogwidgets/code/widgetwithbackground.cpp:26: undefined reference to `vtable for WidgetWithBackground'
    ../AnalogWidgets/analogwidgets/code/widgetwithbackground.cpp:26: undefined reference to `vtable for WidgetWithBackground'
    debug/widgetwithbackground.o: In function `~WidgetWithBackground':
    ../AnalogWidgets/analogwidgets/code/widgetwithbackground.cpp:32: undefined reference to `vtable for WidgetWithBackground'
    ../AnalogWidgets/analogwidgets/code/widgetwithbackground.cpp:32: more undefined references to `vtable for WidgetWithBackground' follow
    plug1-build-desktop/debug/moc_wallclock.cpp:89: undefined reference to `WidgetWithBackground::qt_metacast(char const*)'
    plug1-build-desktop/debug/moc_wallclock.cpp:94: undefined reference to `WidgetWithBackground::qt_metacall(QMetaObject::Ca ll, int, void**)'
    debug/moc_wallclock.o:moc_wallclock.cpp.rdata+0x0): undefined reference to `WidgetWithBackground::staticMetaObject'
    plug1-build-desktop/debug/moc_led.cpp:71: undefined reference to `WidgetWithBackground::qt_metacast(char const*)'
    plug1-build-desktop/debug/moc_led.cpp:76: undefined reference to `WidgetWithBackground::qt_metacall(QMetaObject::Ca ll, int, void**)'
    debug/moc_led.o:moc_led.cpp.rdata+0x0): undefined reference to `WidgetWithBackground::staticMetaObject'
    collect2: ld returned 1 exit status


    ( This file is used by led.h and wallclock.h (#include "widgetwithbackground.h"))

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: INCLUDEPATH how it works ?

    Rerun qmake.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: INCLUDEPATH how it works ?

    I'm using QT Creator ...

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: INCLUDEPATH how it works ?

    Then rerun qmake under Qt Creator.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #8
    Join Date
    Oct 2010
    Location
    Cracow,Bielsko-Biała/Polska
    Posts
    15
    Thanks
    3
    Platforms
    Unix/X11 Windows

    Default Re: INCLUDEPATH how it works ?

    Press Right Mouse button -> clean project -> Run qmake. Should working.

  9. #9
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: INCLUDEPATH how it works ?

    Qmake does :

    Starting: "d:/qt/2010.04/qt/bin/qmake.exe" d:/c++/plug1/plug1.pro -r -spec win32-g++
    The process "d:/qt/2010.04/qt/bin/qmake.exe" exited normally.

    And nothing more... (My application is not launched)
    Then, if I do click on 'run' project all the building process is launched again with the same errors.

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: INCLUDEPATH how it works ?

    Tonnot, please do me a favour. Go through the basic Qt programming tutorial available in Qt documentation. Then get a decent book on C++ programming and read it. We're not here to teach you programming. And you obviously lack the basic knowledge regarding software development.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #11
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: INCLUDEPATH how it works ?

    Yes, because of it I am here (newbie)
    Sincerely, I dont know what is happen.
    And my main question (the errors I get If I have the INCLUDEPATH ok but not have the .h file added at .pro file) is still without solution ...
    Thanks

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: INCLUDEPATH how it works ?

    This is a Qt forum. We're helping with Qt issues. Not with I-don't-know-how-to-program issues. The "newbie" forum is for Qt newbies, not programming newbies. You have to learn by yourself how a compiler works, what are include files, etc.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  13. #13
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: INCLUDEPATH how it works ?

    Excuse me, but I think that I am not making so basic questions.
    Of course, I'm learning c++ but I am not asking about how to declare a variable....

    And my main question (the errors I get If I have the INCLUDEPATH ok but not have the .h file added at .pro file) is still without solution ...
    Thanks

  14. #14
    Join Date
    Sep 2010
    Posts
    45
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: INCLUDEPATH how it works ?

    Quote Originally Posted by tonnot View Post
    I'm using QT Creator ...
    main menu > build > run qmake

  15. #15
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: INCLUDEPATH how it works ?

    If I delete ../AnalogWidgets/analogwidgets/analogwidgets/widgetwithbackground.h \ i have :
    Why would you do that if:
    This file is used by led.h and wallclock.h (#include "widgetwithbackground.h")
    and presumably also by widgetwithbackground.cpp.

    By removing this file, containing a Q_OBJECT macro, from HEADERS you are telling Qt that it doesn't need to run moc (or anything else) on this file... so it doesn't. This means that the code moc generates on your behalf is not generated, which includes the "vtable" referenced in the error messages from your linker.

    The INCLUDEPATH tells the C++ compiler how to find headers other than those in default locations, which it is clearly doing or your code would not compile. It has no bearing on moc.

    In short, if you deliberately break it then you get to keep the pieces.

  16. #16
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: INCLUDEPATH how it works ?

    This is the text showed by the QT HELP:

    INCLUDEPATH
    This variable specifies the #include directories which should be searched when compiling the project. Use ';' or a space as the directory separator.


    So, finally ... INCLUDEPATH fails with #include's ?
    Thanks for the answers (specially from then last 3 )

  17. #17
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: INCLUDEPATH how it works ?

    No, it doesn't fail with anything. It's just a place where to look for header fiiles. Your problem is not that some header files were not found.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  18. #18
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: INCLUDEPATH how it works ?

    Thanks, WY (and sincerely thank you very much for your patience)
    So finally, If you are going to use some custom widgets (using promoting aproach) be carefull to add 'by hand' all the dependant files, isn't it ?
    Thanks again

  19. #19
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: INCLUDEPATH how it works ?

    Using custom widgets "using promoting approach" is no different than using them directly in hand-written C++ code. You always need to add the header and implementation file (provided they exist) to the project.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  20. #20
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: INCLUDEPATH how it works ?

    Quote Originally Posted by tonnot View Post
    INCLUDEPATH
    This variable specifies the #include directories which should be searched when compiling the project. Use ';' or a space as the directory separator.
    Notice the words "when compiling the project". That is to say, the paths are sent to the C++ compiler as -I options or their equivalent. There a literally hundreds of include files involved in compiling your project, many (most) of which have nothing directly relating them to Qt. Qt does not assume that every possible include file is part of your project and does not scan every one of these files for the Q_OBJECT or other markers that trigger Qt code generation. Qmake uses the HEADERS variable to identify files that are part of your project and should be scanned for pre-processing triggers and, when found, generate and compile extra C++ source on your behalf.

    In your case the C++ compiler is finding everything it needs to compile the project. The linker fails because code that is generated on your behalf has not been generated and included in the compilation, i.e. HEADERS is wrong.

  21. The following user says thank you to ChrisW67 for this useful post:

    tonnot (29th October 2010)

Similar Threads

  1. Creator 4.5.2 crash adding INCLUDEPATH
    By PUK_999 in forum Newbie
    Replies: 11
    Last Post: 17th August 2009, 20:38
  2. Replies: 1
    Last Post: 2nd December 2008, 11:31
  3. another qmake INCLUDEPATH spaces problem
    By mmueller in forum Qt Programming
    Replies: 4
    Last Post: 31st July 2008, 14:12
  4. qmake multiple INCLUDEPATH in Linux
    By rajeshs in forum Qt Programming
    Replies: 12
    Last Post: 15th November 2007, 10:38
  5. qmake INCLUDEPATH with spaces
    By bitChanger in forum Qt Programming
    Replies: 8
    Last Post: 28th April 2006, 05:39

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.