Trouble Building Qt4 Plugin - moc not being invoked?

Andreas Pakulat apaku at gmx.de
Sat Apr 28 08:21:25 UTC 2012


Hi

On Sat, Apr 28, 2012 at 06:56, Lindsay Mathieson <
lindsay.mathieson at gmail.com> wrote:

> **
>
> Searching on google seems to indicate an issue with moc not being invoked.
> Have been banging my head aginst this for days now.
>
>
>
> Trying to build a shared plugin for QtWebKit, which uses the Qt4 plugin
> systems but can't get past the following link errors:
>
>
>
> Linking CXX shared library lib/libkdewebkit-spellplugin.so
>
> CMakeFiles/kdewebkit-spellplugin.dir/kspellplugin.o: In function
> `KWebKitSpellChecker':
>
> /data/dev/kdewebkit-spellplugin/kspellplugin.h:19: undefined reference to
> `vtable for KWebKitSpellChecker'
>
> CMakeFiles/kdewebkit-spellplugin.dir/kspellplugin.o: In function
> `TestQWebKitPlatformPlugin':
>
> /data/dev/kdewebkit-spellplugin/kspellplugin.h:47: undefined reference to
> `vtable for TestQWebKitPlatformPlugin'
>
> collect2: ld returned 1 exit status
>
> make[2]: *** [lib/libkdewebkit-spellplugin.so] Error 1
>
> make[1]: *** [CMakeFiles/kdewebkit-spellplugin.dir/all] Error 2
>
> make: *** [all] Error 2
>
> *** Failed ***
>

Not really something to do with kdevelop, but yes moc does not seem to be
run or the resulting file is not
included into the plugin.


> My cmake file is pretty basic:
>
>
>
>    - project(kdewebkit-spellplugin)
>    -
>    - find_package(KDE4 REQUIRED)
>    - FIND_PACKAGE(Qt4 REQUIRED)
>    -
>    - include (KDE4Defaults)
>    -
>    -
>    include_directories(/data/dev/webkit-blackpaws-kde-qt-webkit/Source/WebKit/qt/Api)
>    - include_directories( ${KDE4_INCLUDES} ${QT_INCLUDES} )
>    -
>    -
>    - ADD_LIBRARY(kdewebkit-spellplugin SHARED kspellplugin.cpp
>    kspellplugin.h)
>
>
You should use MODULE here not SHARED, since a plugin is not a shared
library and usually doesn't get a soversion set or the version-symlinks.

More importantly though, since you use the basic CMake commands instead of
the KDE wrappers, you need to add the moc-step yourself. You should use
QT4_WRAP_CPP to do that and include the generated files into your plugin.
This also means you need to remove a #include "kspellplugin.moc" in your
cpp file if it exists.

Andreas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop/attachments/20120428/92bca12f/attachment.html>


More information about the KDevelop mailing list