[Interest] Link Errors when Creating a Windows DLL containing Qt Widgets

Till Oliver Knoll till.oliver.knoll at gmail.com
Mon May 14 20:00:12 CEST 2012

Am 14.05.2012 um 16:35 schrieb Mike Jackson <imikejackson at gmail.com>:

> ...
> 19>QLeeMarchingCubesWidget.obj : error LNK2001: unresolved external
> symbol "public: static struct QMetaObject const
> QFilterWidget::staticMetaObject"
> (?

Hmmm, it just crossed my mind that something else could go wrong here: staticMetaObject is off course a moc generated function. So even if you declare the whole class (the public fields thereof, according to the MSDN article) to be "exported" (just as you do) the compiler cannot possibly know the (not yet existing) public symbol "staticMetaObject" and have it exported later on.

This is not a problem as long as this symbol is not referenced from OUTSIDE of that particular DLL. But it seems that this is exactly the case here (that your plugin DLL is explicitly trying to call QFilterWidget::staticMetaObject - where does this call come from exactly?).

The good news is off course that it /is/ possible to write DLLs, even with QWidgets inside, and off course one can also derive from those widgets and connect to signals which are declared in the Qt DLLs - as proven by QtGui itself ;)

Maybe open an existing widget's source code and check whether there is some special mechanism (macro) which makes sure that also generated code is exported (?). 


More information about the Interest mailing list