1 Attachment(s)
"Undefined reference to `QwtPlot::QwtPlot(QWidget*)'
Hi everyone. I am experiencing a problem while using the QwtPlot library.
I have created a plot class, which inherits the QwtPlot library. However, When I try to run I get errors "Undefined reference to `QwtPlot::QwtPlot(QWidget*)'.
plot.h
Code:
#ifndef PLOT_H
#define PLOT_H
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
{
public:
plot();
virtual ~plot();
private:
};
#endif // PLOT_H
plot.cpp
Code:
#include "plot.h"
plot::plot()
{
}
plot::~plot()
{
}
However, If i don't inherit the QwtPlot then everything works and I don't get any error for QwtPlotCurve (which shows that QWT is installed correctly).
Any suggestion on how to resolve this inheritance issue?
Re: "Undefined reference to `QwtPlot::QwtPlot(QWidget*)'
Hi, this is a linker error. Do you link against the qwt library?
Ginsengelf
Re: "Undefined reference to `QwtPlot::QwtPlot(QWidget*)'
Quote:
Originally Posted by
Ginsengelf
Hi, this is a linker error. Do you link against the qwt library?
Ginsengelf
I used the following commands to link the Qwt with Qtcreator.
Code:
ln -s /opt/qwt-6.1.0/plugins/designer/libqwt_designer_plugin.so /opt/Qt5.1.1/Tools/QtCreator/bin/plugins/designer/
echo /opt/qwt-6.1.0/lib | tee /etc/ld.so.conf.d/qwt.conf
ldconfig -v
Re: "Undefined reference to `QwtPlot::QwtPlot(QWidget*)'
Quote:
ln -s /opt/qwt-6.1.0/plugins/designer/libqwt_designer_plugin.so /opt/Qt5.1.1/Tools/QtCreator/bin/plugins/designer/
This command is linking against the Qwt plugin for Qt Designer, not the Qwt library itself.
Your code also inherits privately from QwtPlot, which is not recommended. Your declaration for class plot should be:
Quote:
I don't get any error for QwtPlotCurve (which shows that QWT is installed correctly).
No, all you have done is declare a member variable that is a pointer to a QwtPlotCurve instance, which you don't actually instantiate (with "new") in the cpp file. So the compiler and linker are perfectly happy with that since nothing needs to be known about a pointer that is never used. It isn't proof of anything.