[Qt-interest] Qt plugin error: undefined reference to `MainWindow::staticMetaObject'

Thiago Macieira thiago at kde.org
Wed Apr 28 09:42:54 CEST 2010


Em Quarta-feira 28. Abril 2010, às 08.39.04, 程梁 escreveu:
> D:/Develop/Qt/2010.02.1/qt/include/QtCore/../../src/corelib/kernel/qobject.
> h:455: undefined reference to `MainWindow::staticMetaObject'

> int main(int argc, char *argv[])
> {
>     QApplication a(argc, argv);
>     QPluginLoader pluginLoader("ui.dll");
>     if(pluginLoader.load()) {
>         QObject *obj = pluginLoader.instance();
>         QMessageBox::information(NULL, "plugin",
> obj->metaObject()->className());
>         // MainWindow *win = qobject_cast<MainWindow *>(obj);
>         // win->setVisible(true);
>     }
>     return a.exec();
> }
> 
> Could you tell me how to solve this problem? Thank you!

Where is MainWindow defined? From the error you're getting, the .h header 
includes a Q_OBJECT macro.

Is the header listed in the HEADERS line for the library? Is the application 
above linked to that library?

Do you even have a library?

Remember, when you have a plugin, you MUST have two components at least:
 1) a library
 2) the plugin
 3) optional: an application

You pasted the code above for the optional part. Where's the library? Both the 
plugin and the application must link to this library.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Senior Product Manager - Nokia, Qt Development Frameworks
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100428/d9b1e5e5/attachment.bin 


More information about the Qt-interest-old mailing list