Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unresolved external symbol: QMetaObject const QwtPlotMagnifier::staticMetaObject

Tags:

c++

qt

qwt

I have a library that uses QwtPlotMagnifier, amongst other Qwt classes. I decided to subclass QwtPlotMagnifier so that I can emit a signal when the plot is rescaled. The library (mylib.lib) compiles, but the application using it is now complaining about an unresolved external related to the moc output of QwtPlotMagnifier.

I am linking qwt statically; so the requirement to have the preprocessor directive QWT_DLL in the lowest level library doesn't apply here.

Here's the error (the subclass is called PlotMagnifier):

mylib.lib(moc_PlotMagnifier.obj) : error LNK2001: unresolved external symbol "public: static struct QMetaObject const QwtPlotMagnifier::staticMetaObject" (?staticMetaObject@QwtPlotMagnifier@@2UQMetaObject@@B)

Nothing special about the subclass declaration:

#pragma once

#include "qwt_plot_magnifier.h"
/**
subclass of QwtPlotMagnifier to provide a signal when zooming is complete
*/
class PlotMagnifier : public QwtPlotMagnifier
{
    Q_OBJECT
public:
  explicit PlotMagnifier(QWidget *w);
  virtual ~PlotMagnifier();
signals:
  void rescaled();
protected:
  virtual void rescale(double factor);  
};

I'm on visual studio 2013 fwiw. My application still includes qwtd.lib as it always has. This has got to be a stupid mistake on my part.. kickstart my brain please, someone!

like image 986
mike Avatar asked Feb 23 '26 11:02

mike


1 Answers

Add this line to .pro file to give the compiler a hint for an external symbol:

DEFINES += QWT_DLL

In the file qwt_global.h have the macro. Without this macro, the compiler will think this is an internal symbol.

like image 100
mohabouje Avatar answered Feb 24 '26 23:02

mohabouje