Reputation: 1322
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!
Upvotes: 3
Views: 2312
Reputation: 4050
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.
Upvotes: 2
Reputation: 548
Check, if you have all needed includes in you Visual Studio project.
C/C++ / Additional Include Directories
Here should be a path to <qwt_dir\include>
be
Linker / General / Additional Library Directories
Here should be a path to <qwt_dir\lib>
be
Linker / Input
Should include qwtd.lib
(for debug
configuration) and qwt.lib
(for release
)
Also, check that you have those entries in Release
and Debug
configurations, it is easy to configure only Debug
, while working on Release
configuration.
Also, check that you have moc_*
file (something like moc_plotmagnifier.cpp
) for your PlotMagnifier
under Generated Files
in your project view, sometimes Qt addin fails to add them.
Upvotes: 0