Results 1 to 5 of 5

Thread: includepath problem ? error of undefined reference ...

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

    Default includepath problem ? error of undefined reference ...

    this is my pro file, in trying to test a widget placed at a knowed path.
    (I'm trying to test the analogwidgets from www.3electrons.com )

    Qt Code:
    1. TEMPLATE = app
    2. INCLUDEPATH += ../AnalogWidgets/analogwidgets/analogwidgets \
    3. ../AnalogWidgets/analogwidgets/code
    4.  
    5. HEADERS += ../AnalogWidgets/analogwidgets/analogwidgets/led.h \
    6. form.h
    7.  
    8. SOURCES += ../AnalogWidgets/analogwidgets/code/led.cpp \
    9. form.cpp \
    10. main.cpp
    11.  
    12. FORMS += \
    13. form.ui
    To copy to clipboard, switch view to plain text mode 

    led.h has :
    #include "widgetwithbackground.h" and this file is placed at the same location as led.h

    ok, when compile I have the errors : one of them (all are similar ) are :

    ... line 27 : undefined reference to `WidgetWithBackground::WidgetWithBackground(QWidge t*)'

    This is the 27 and more lines of led.h:

    Qt Code:
    1. Led::Led(QWidget * parent):WidgetWithBackground(parent)
    2. {
    3. m_checked = true;
    4. m_color = Qt::red;
    5. resize(330,330);
    6. }
    To copy to clipboard, switch view to plain text mode 


    Any help ?

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

    Default Re: includepath problem ? error of undefined reference ...

    Hello.

    Try smth like below.

    Qt Code:
    1. HEADERS += ../AnalogWidgets/analogwidgets/analogwidgets/led.h \
    2. ../AnalogWidgets/analogwidgets/analogwidgets/widgetwithbackground.h \
    3. form.h
    4.  
    5. SOURCES += ../AnalogWidgets/analogwidgets/code/led.cpp \
    6. ../AnalogWidgets/analogwidgets/code/widgetwithbackground.cpp \
    7. form.cpp \
    8. main.cpp
    To copy to clipboard, switch view to plain text mode 

    Entry "...widgetwithbackground.cpp" should be added only if you have cpp file. You didn`t write informations about it.

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

    Default Re: includepath problem ? error of undefined reference ...

    And ... What is the intended of INCLUDEPATH ?
    Thanks

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

    Default Re: includepath problem ? error of undefined reference ...

    Quote Originally Posted by tonnot View Post
    ... line 27 : undefined reference to `WidgetWithBackground::WidgetWithBackground(QWidge t*)'

    This is the 27 and more lines of led.h:

    Qt Code:
    1. Led::Led(QWidget * parent):WidgetWithBackground(parent)
    To copy to clipboard, switch view to plain text mode 
    Do you understand this compiler error? Do you know which piece of code makes it appear?
    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.


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

    Default Re: includepath problem ? error of undefined reference ...

    Quote Originally Posted by tonnot View Post
    ok, when compile I have the errors : one of them (all are similar ) are :
    ... line 27 : undefined reference to `WidgetWithBackground::WidgetWithBackground(QWidge t*)'
    Above message is generated by linker. Propably, linker couldn`t find definition of WidgetWithBackground(library can be missed or cpp file didn`t compile or something like that). It isn`t involve with "h" files, rather with "cpp" or "lib".
    Last edited by Leszek; 27th October 2010 at 19:19.

Similar Threads

  1. Getting Undefined Reference Error
    By A.H.M. Mahfuzur Rahman in forum Qt Programming
    Replies: 2
    Last Post: 22nd June 2009, 02:12
  2. Error - undefined reference qMain
    By tpf80 in forum Newbie
    Replies: 4
    Last Post: 23rd February 2009, 07:54
  3. Error : undefined reference to `vtable for MyClass'
    By joseph in forum Qt Programming
    Replies: 23
    Last Post: 15th June 2007, 11:21
  4. error undefined reference ...............
    By amit_pansuria in forum Qt Programming
    Replies: 2
    Last Post: 8th June 2007, 14:28
  5. Undefined Reference error!!!
    By Kapil in forum Newbie
    Replies: 25
    Last Post: 28th March 2006, 12:03

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.