PDA

View Full Version : Cannot compile examples



jmalicke
17th July 2014, 07:26
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:


$ cd /usr/src/qwt-6.1.0/examples
$ qmake
$ make
...
make[1]: Entering directory `/usr/src/qwt-6.1.0/examples/animation'
linking ../bin/animation
/usr/local/qwt-6.1.0/lib/libqwt.so: undefined reference to `QMetaType::unregisterConverterFunction(int, int)'
/usr/local/qwt-6.1.0/lib/libqwt.so: undefined reference to `QMetaType::registerConverterFunction(QtPrivate::A bstractConverterFunction const*, int, int)'
/usr/local/qwt-6.1.0/lib/libqwt.so: undefined reference to `QScrollArea::viewportSizeHint() const'
/usr/local/qwt-6.1.0/lib/libqwt.so: undefined reference to `QMetaType::hasRegisteredConverterFunction(int, int)'
collect2: error: ld returned 1 exit status

This is kind of odd. What am I missing?

Uwe
17th July 2014, 08:06
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

jmalicke
17th July 2014, 17:04
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.

Uwe
17th July 2014, 17:39
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.



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

jmalicke
17th July 2014, 22:53
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:


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
/usr/local/qwt-6.1.0/lib/libqwt.so: undefined reference to `QMetaType::unregisterConverterFunction(int, int)'
/usr/local/bin/qt/5.2.1/gcc_64/lib/libQt5PrintSupport.so.5: undefined reference to `vtable for QDialogPrivate'
/usr/local/bin/qt/5.2.1/gcc_64/lib/libQt5PrintSupport.so.5: undefined reference to `QDialogPrivate::canBeNativeDialog() const'
/usr/local/qwt-6.1.0/lib/libqwt.so: undefined reference to `QMetaType::registerConverterFunction(QtPrivate::A bstractConverterFunction const*, int, int)'
/usr/local/bin/qt/5.2.1/gcc_64/lib/libQt5PrintSupport.so.5: undefined reference to `typeinfo for QDialogPrivate'
/usr/local/qwt-6.1.0/lib/libqwt.so: undefined reference to `QScrollArea::viewportSizeHint() const'
/usr/local/bin/qt/5.2.1/gcc_64/lib/libQt5OpenGL.so.5: undefined reference to `QOpenGLExtensionMatcher::QOpenGLExtensionMatcher( )'
/usr/local/qwt-6.1.0/lib/libqwt.so: undefined reference to `QMetaType::hasRegisteredConverterFunction(int, int)'
/usr/local/bin/qt/5.2.1/gcc_64/lib/libQt5PrintSupport.so.5: undefined reference to `QComboBox::currentData(int) const'
collect2: error: ld returned 1 exit status
make: *** [qwt] Error 1

Here is the very simple .pro file


TARGET = qwt
TEMPLATE = app
QT += widgets
CONFIG += qwt

SOURCES += src/simpleplot.cpp

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


#include <qapplication.h>
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
#include <qwt_plot_grid.h>
#include <qwt_symbol.h>
#include <qwt_legend.h>

int main( int argc, char **argv )
{
QApplication a( argc, argv );

QwtPlot plot;
plot.setTitle( "Plot Demo" );
plot.setCanvasBackground( Qt::white );
plot.setAxisScale( QwtPlot::yLeft, 0.0, 10.0 );
plot.insertLegend( new QwtLegend() );

QwtPlotGrid *grid = new QwtPlotGrid();
grid->attach( &plot );

QwtPlotCurve *curve = new QwtPlotCurve();
curve->setTitle( "Some Points" );
curve->setPen( Qt::blue, 4 ),
curve->setRenderHint( QwtPlotItem::RenderAntialiased, true );

QwtSymbol *symbol = new QwtSymbol( QwtSymbol::Ellipse,
QBrush( Qt::yellow ), QPen( Qt::red, 2 ), QSize( 8, 8 ) );
curve->setSymbol( symbol );

QPolygonF points;
points << QPointF( 0.0, 4.4 ) << QPointF( 1.0, 3.0 )
<< QPointF( 2.0, 4.5 ) << QPointF( 3.0, 6.8 )
<< QPointF( 4.0, 7.9 ) << QPointF( 5.0, 7.1 );
curve->setSamples( points );

curve->attach( &plot );

plot.resize( 600, 400 );
plot.show();

return a.exec();
}

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.