Results 1 to 5 of 5

Thread: Cannot compile examples

  1. #1
    Join Date
    Jun 2014
    Posts
    30
    Thanks
    4
    Qt products
    Qt5

    Default Cannot compile examples

    I've installed qwt to /usr/local/qwt-6.1.0 and I put the source in /usr/src/qwt-6.1.0. When I try to compile the examples with qmake/make I get the following problem:

    Qt Code:
    1. $ cd /usr/src/qwt-6.1.0/examples
    2. $ qmake
    3. $ make
    4. ...
    5. make[1]: Entering directory `/usr/src/qwt-6.1.0/examples/animation'
    6. linking ../bin/animation
    7. /usr/local/qwt-6.1.0/lib/libqwt.so: undefined reference to `QMetaType::unregisterConverterFunction(int, int)'
    8. /usr/local/qwt-6.1.0/lib/libqwt.so: undefined reference to `QMetaType::registerConverterFunction(QtPrivate::AbstractConverterFunction const*, int, int)'
    9. /usr/local/qwt-6.1.0/lib/libqwt.so: undefined reference to `QScrollArea::viewportSizeHint() const'
    10. /usr/local/qwt-6.1.0/lib/libqwt.so: undefined reference to `QMetaType::hasRegisteredConverterFunction(int, int)'
    11. collect2: error: ld returned 1 exit status
    To copy to clipboard, switch view to plain text mode 

    This is kind of odd. What am I missing?

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,309
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Cannot compile examples

    Usually the examples are linked against the libs that have been build before in /usr/src/qwt-6.1.0/lib - in your case they seem to be linked against different ones, that have been installed before in /usr/local/qwt-6.1.0/lib.
    ( Note that this is special for the examples, regular applications should indeed link against the version installed in /usr/local/qwt-6.1.0/lib ),

    If you didn't patch the project files yourself, disable "CONFIG += silent" in qwtbuild.pri, so that we can see, why the examples try to link the wrong libs.

    Uwe

  3. #3
    Join Date
    Jun 2014
    Posts
    30
    Thanks
    4
    Qt products
    Qt5

    Default Re: Cannot compile examples

    I added /usr/src/qwt-6.1.0/lib to /etc/ld.so.conf which is why those libs were being picked up. I removed the entry and it compiles great. So thank you for that!!

    Can I ask why the examples are "special" from ordinary applications? Why do they use different libraries? I'm using the examples to learn how to do Qwt in my application but it strikes me odd that what I am learning is not supported by the installed libs.

  4. #4
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,309
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Cannot compile examples

    Quote Originally Posted by jmalicke View Post
    I added /usr/src/qwt-6.1.0/lib to /etc/ld.so.conf which is why those libs were being picked up.
    ld.so.conf is for linking dynamically at runtime and doesn't explain any issues, when building an application. So whatever you did - I question, that this was the solution.

    Quote Originally Posted by jmalicke View Post
    Can I ask why the examples are "special" from ordinary applications? Why do they use different libraries?
    In general libraries ( and applications ) are build locally and installed somewhere later in an extra step - usually by "make install".

    The Qwt examples are part of the Qwt package and the intention is that you can build them without having to install something. That's why they are linked against the local libs. Of course they could be linked against installed libs as well, but the project files ( -> makefiles ) of the examples are not written this way.

    Uwe

  5. #5
    Join Date
    Jun 2014
    Posts
    30
    Thanks
    4
    Qt products
    Qt5

    Default Re: Cannot compile examples

    Quote Originally Posted by Uwe View Post
    ld.so.conf is for linking dynamically at runtime and doesn't explain any issues, when building an application. So whatever you did - I question, that this was the solution.
    Ah, good point. I'm not sure what I did differently.

    When I try to make my own simpleplot project based of the example I get the following error during building:

    Qt Code:
    1. g++ -m64 -Wl,-O1 -o qwt simpleplot.o -L/usr/X11R6/lib64 -L/usr/local/qwt-6.1.0/lib -lqwt -lQt5Svg -L/usr/lib/x86_64-linux-gnu -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread
    2. /usr/local/qwt-6.1.0/lib/libqwt.so: undefined reference to `QMetaType::unregisterConverterFunction(int, int)'
    3. /usr/local/bin/qt/5.2.1/gcc_64/lib/libQt5PrintSupport.so.5: undefined reference to `vtable for QDialogPrivate'
    4. /usr/local/bin/qt/5.2.1/gcc_64/lib/libQt5PrintSupport.so.5: undefined reference to `QDialogPrivate::canBeNativeDialog() const'
    5. /usr/local/qwt-6.1.0/lib/libqwt.so: undefined reference to `QMetaType::registerConverterFunction(QtPrivate::AbstractConverterFunction const*, int, int)'
    6. /usr/local/bin/qt/5.2.1/gcc_64/lib/libQt5PrintSupport.so.5: undefined reference to `typeinfo for QDialogPrivate'
    7. /usr/local/qwt-6.1.0/lib/libqwt.so: undefined reference to `QScrollArea::viewportSizeHint() const'
    8. /usr/local/bin/qt/5.2.1/gcc_64/lib/libQt5OpenGL.so.5: undefined reference to `QOpenGLExtensionMatcher::QOpenGLExtensionMatcher()'
    9. /usr/local/qwt-6.1.0/lib/libqwt.so: undefined reference to `QMetaType::hasRegisteredConverterFunction(int, int)'
    10. /usr/local/bin/qt/5.2.1/gcc_64/lib/libQt5PrintSupport.so.5: undefined reference to `QComboBox::currentData(int) const'
    11. collect2: error: ld returned 1 exit status
    12. make: *** [qwt] Error 1
    To copy to clipboard, switch view to plain text mode 

    Here is the very simple .pro file

    Qt Code:
    1. TARGET = qwt
    2. TEMPLATE = app
    3. QT += widgets
    4. CONFIG += qwt
    5.  
    6. SOURCES += src/simpleplot.cpp
    To copy to clipboard, switch view to plain text mode 

    And finally, here is simpleplot.cpp (essentially copied from the examples folder)

    Qt Code:
    1. #include <qapplication.h>
    2. #include <qwt_plot.h>
    3. #include <qwt_plot_curve.h>
    4. #include <qwt_plot_grid.h>
    5. #include <qwt_symbol.h>
    6. #include <qwt_legend.h>
    7.  
    8. int main( int argc, char **argv )
    9. {
    10. QApplication a( argc, argv );
    11.  
    12. QwtPlot plot;
    13. plot.setTitle( "Plot Demo" );
    14. plot.setCanvasBackground( Qt::white );
    15. plot.setAxisScale( QwtPlot::yLeft, 0.0, 10.0 );
    16. plot.insertLegend( new QwtLegend() );
    17.  
    18. QwtPlotGrid *grid = new QwtPlotGrid();
    19. grid->attach( &plot );
    20.  
    21. QwtPlotCurve *curve = new QwtPlotCurve();
    22. curve->setTitle( "Some Points" );
    23. curve->setPen( Qt::blue, 4 ),
    24. curve->setRenderHint( QwtPlotItem::RenderAntialiased, true );
    25.  
    26. QwtSymbol *symbol = new QwtSymbol( QwtSymbol::Ellipse,
    27. QBrush( Qt::yellow ), QPen( Qt::red, 2 ), QSize( 8, 8 ) );
    28. curve->setSymbol( symbol );
    29.  
    30. QPolygonF points;
    31. points << QPointF( 0.0, 4.4 ) << QPointF( 1.0, 3.0 )
    32. << QPointF( 2.0, 4.5 ) << QPointF( 3.0, 6.8 )
    33. << QPointF( 4.0, 7.9 ) << QPointF( 5.0, 7.1 );
    34. curve->setSamples( points );
    35.  
    36. curve->attach( &plot );
    37.  
    38. plot.resize( 600, 400 );
    39. plot.show();
    40.  
    41. return a.exec();
    42. }
    To copy to clipboard, switch view to plain text mode 


    Added after 1 26 minutes:


    I did a simple rebuild of qwt and it solved my compile/linker problems. Now when I run the app I get

    "Segmentation fault"

    With no other info.

    Why is this so hard for me ?!

    EDIT: The problem was another qwt lib that was incompatible. I solved it with ldd. Finally working. I still have no idea what the problems were. Seemed my first builds just weren't working for some reason.
    Last edited by jmalicke; 17th July 2014 at 23:57.

Similar Threads

  1. Error when compile/run Qt examples
    By babygal in forum Newbie
    Replies: 5
    Last Post: 9th March 2011, 12:51
  2. how can i don't compile qt demos and examples?
    By rainspider in forum Installation and Deployment
    Replies: 4
    Last Post: 7th November 2009, 17:58
  3. to compile and run qtopia examples for greenphone
    By prajna in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 15th April 2009, 11:00
  4. Qt State Machine Examples don't compile
    By vitalyx in forum Newbie
    Replies: 0
    Last Post: 4th April 2009, 15:19
  5. compile opengl examples
    By balinsky in forum Qt Programming
    Replies: 5
    Last Post: 16th February 2009, 01:33

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.