PDA

View Full Version : includepath problem ? error of undefined reference ...



tonnot
26th October 2010, 20:41
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 )


TEMPLATE = app
INCLUDEPATH += ../AnalogWidgets/analogwidgets/analogwidgets \
../AnalogWidgets/analogwidgets/code

HEADERS += ../AnalogWidgets/analogwidgets/analogwidgets/led.h \
form.h

SOURCES += ../AnalogWidgets/analogwidgets/code/led.cpp \
form.cpp \
main.cpp

FORMS += \
form.ui

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:


Led::Led(QWidget * parent):WidgetWithBackground(parent)
{
m_checked = true;
m_color = Qt::red;
resize(330,330);
}


Any help ?

Leszek
26th October 2010, 22:25
Hello.

Try smth like below.



HEADERS += ../AnalogWidgets/analogwidgets/analogwidgets/led.h \
../AnalogWidgets/analogwidgets/analogwidgets/widgetwithbackground.h \
form.h

SOURCES += ../AnalogWidgets/analogwidgets/code/led.cpp \
../AnalogWidgets/analogwidgets/code/widgetwithbackground.cpp \
form.cpp \
main.cpp


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

tonnot
27th October 2010, 09:50
And ... What is the intended of INCLUDEPATH ?
Thanks

wysota
27th October 2010, 13:15
... line 27 : undefined reference to `WidgetWithBackground::WidgetWithBackground(QWidge t*)'

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


Led::Led(QWidget * parent):WidgetWithBackground(parent)


Do you understand this compiler error? Do you know which piece of code makes it appear?

Leszek
27th October 2010, 20:08
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".