Results 1 to 4 of 4

Thread: "Undefined reference to `QwtPlot::QwtPlot(QWidget*)'

  1. #1
    Join Date
    Jul 2021
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default "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
    Qt Code:
    1. #ifndef PLOT_H
    2. #define PLOT_H
    3. #include <qwt_plot.h>
    4. #include <qwt_plot_curve.h>
    5.  
    6. class plot : QwtPlot
    7. {
    8. public:
    9. plot();
    10. virtual ~plot();
    11.  
    12. private:
    13. QwtPlotCurve* curve_data;
    14. };
    15.  
    16. #endif // PLOT_H
    To copy to clipboard, switch view to plain text mode 
    plot.cpp

    Qt Code:
    1. #include "plot.h"
    2.  
    3. plot::plot()
    4. {
    5. }
    6.  
    7. plot::~plot()
    8. {
    9. }
    To copy to clipboard, switch view to plain text mode 


    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?
    Attached Images Attached Images

  2. #2
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    474
    Thanks
    10
    Thanked 62 Times in 60 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: "Undefined reference to `QwtPlot::QwtPlot(QWidget*)'

    Hi, this is a linker error. Do you link against the qwt library?

    Ginsengelf

  3. #3
    Join Date
    Jul 2021
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: "Undefined reference to `QwtPlot::QwtPlot(QWidget*)'

    Quote Originally Posted by Ginsengelf View Post
    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.

    Qt Code:
    1. ln -s /opt/qwt-6.1.0/plugins/designer/libqwt_designer_plugin.so /opt/Qt5.1.1/Tools/QtCreator/bin/plugins/designer/
    2. echo /opt/qwt-6.1.0/lib | tee /etc/ld.so.conf.d/qwt.conf
    3. ldconfig -v
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,023
    Thanks
    280
    Thanked 818 Times in 807 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: "Undefined reference to `QwtPlot::QwtPlot(QWidget*)'

    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:

    Qt Code:
    1. class plot : public QwtPlot
    2. {
    3. // ...
    4. };
    To copy to clipboard, switch view to plain text mode 

    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.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Replies: 1
    Last Post: 2nd August 2019, 16:33
  2. Replies: 2
    Last Post: 13th March 2017, 06:59
  3. Replies: 10
    Last Post: 19th September 2012, 15:13
  4. Replies: 0
    Last Post: 15th July 2011, 03:21
  5. Replies: 6
    Last Post: 14th May 2009, 12:02

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.