PDA

View Full Version : undefined reference to `QwtPlot::qt_metacall(QMetaObject::Call, int, void**)'



Mr_Grieves
22nd January 2009, 01:16
I'm struggling to get a QWT plot into my application with so little documentation -- an official intro/howto guide would be helpful. The few examples lingering around the net are from different versions that use very different syntax, etc....

Ok, /rant.

I'm trying to compile this as a generic plot of y = x^2 for the moment:
histPlot.cpp:


#include <qwt5/qwt_plot.h>
#include <qwt5/qwt_plot_curve.h>
#include "histPlot.h"
#include <QWidget>

HistPlot::HistPlot( QWidget *parent ) : QwtPlot( parent)
{
// Show a title
setTitle( "History" );

// Create curves
QwtPlotCurve * curve = new QwtPlotCurve("Curve");

double x[100], y[100];

for (int i = 0; i < 100; i++){
x[i] = i;
y[i] = i*i;
}

curve->setData(x,y,100);
curve->attach(this);

// Show the plots
replot();

}

But I get this from the compiler:


g++ -o timeClock dialogs.o fileOps.o frame.o histPlot.o main.o mainWindow.o timeFunctions.o timeSheet.o moc_frame.o moc_histPlot.o moc_mainWindow.o -L/usr/lib64/qt4 -lqwt -lQtGui -L/usr/lib64 -L/usr/lib64/qt4 -L/usr/X11R6/lib64 -lpng -lSM -lICE -lXi -lXrender -lXrandr -lXinerama -lfreetype -lfontconfig -lXext -lX11 -lQtCore -lz -lm -lrt -ldl -lpthread
moc_histPlot.o: In function `HistPlot::qt_metacall(QMetaObject::Call, int, void**)':
moc_histPlot.cpp:(.text+0x11): undefined reference to `QwtPlot::qt_metacall(QMetaObject::Call, int, void**)'
moc_histPlot.o: In function `HistPlot::qt_metacast(char const*)':
moc_histPlot.cpp:(.text+0x58): undefined reference to `QwtPlot::qt_metacast(char const*)'
moc_histPlot.o:(.rodata+0x0): undefined reference to `QwtPlot::staticMetaObject'
collect2: ld returned 1 exit status
make: *** [timeClock] Error 1


Neither I nor google have any idea what qt_metacall is, nor why it can't be found. Any ideas?

Mr_Grieves
22nd January 2009, 14:26
The ever-friendly folks in #qt have pointed out that these errors usually result from not moc'ing a header with a Q_OBJECT call. the header for histPlot.cpp does indeed call Q_OBJECT, but it also does get moc'ed. Upon hearing this, #qt told me to find #qwt :) Since #qwt does not exist, I suppose this is the next best thing. Any ideas?

jacek
22nd January 2009, 23:55
Maybe the linker has problems in finding Qwt? Do you have libqwt.so file on your system?

Mr_Grieves
23rd January 2009, 01:38
The qwt library is in my linking path, but it does seem to be a problem with the linker.

Removing Q_OBJECT macro from the histPlot.h header didn't help. Let me know if theres anything else that would be helpful to see -- I'd really like to resolve this quickly :)

Mr_Grieves
23rd January 2009, 01:41
The error changes a bit when Q_OBJECT is removed:


histPlot.o:(.rodata._ZTV8HistPlot[vtable for HistPlot]+0x18): undefined reference to `QwtPlot::qt_metacast(char const*)'
histPlot.o:(.rodata._ZTV8HistPlot[vtable for HistPlot]+0x20): undefined reference to `QwtPlot::qt_metacall(QMetaObject::Call, int, void**)'
collect2: ld returned 1 exit status
make: *** [timeClock] Error 1

Mr_Grieves
24th January 2009, 04:37
Got it working. Updated to the latest Qwt and linking completes.

mendes
28th September 2009, 15:43
I have the same problem, only I'm already using qwt-5.2.0 so I can't update.
This project works on another computer not mine. I can compile and run qwt examples
Any ideas what the problem might be?

jord
2nd October 2009, 15:15
I don't have a build environment handy to verify this advice, but the error looks familiar...

Make sure QWT_DLL is defined in your compiler flags.

mendes
6th October 2009, 11:16
I solved this problem by changing the install dir of qwt to /usr, this in linux

Uwe
7th October 2009, 17:12
I solved this problem by changing the install dir of qwt to /usr, this in linux
Whatever solved the problem in your particular situation - changing the install dir to /usr has absolutely nothing to do with it.

Uwe

barrygp
19th September 2012, 15:13
I receive the same error when I changed qwt from shared lib to static library under linux. any idea what may be the issue? thanks.