简体   繁体   中英

Qt plugin: From qmake to qbs. Linkage error

I have a .pro project consisting of two products:

player.pro

TEMPLATE = subdirs
SUBDIRS = mediaplayer \
          imageplayer 
imageplayer.depends = mediaplayer

madiaplayer.pro - dll lib

TEMPLATE = lib
DEFINES += MEDIAPLAYER_LIBRARY
HEADERS = MediaPlayer_global.h \ <...>
<...>

imageplayer.pro - qt plugin

TEMPLATE = lib
CONFIG += plugin
LIBS *= -L<path to mediaplayer dll>
INCLUDEPATH *= mediaplayer \ <...>
DEPENDPATH *= $$INCLUDEPATH
<...>

It works fine. But now I need qbs version.


I write something like:

player.qbs

Project {
    references: [
        "mediaplayer/MediaPlayer.qbs",
        "imageplayer/ImagePlayer.qbs",
    ]
}

MediaPlayer.qbs

MediaPlayer {
    Group {
        qbs.install: true
        fileTagsFilter: "dynamiclibrary"
    }
    cpp.includePaths: product.sourceDirectory
    cpp.defines: [ product.name.toUpperCase() + "_LIBRARY", ]
    Export {
        cpp.includePaths: product.sourceDirectory
        cpp.defines: [ product.name.toUpperCase() + "_LIBRARY", ]
    }
    <...>
}

ImagePlayer.qbs

ImagePlayer {
    Depends { name: "MediaPlayer" }
    Export { Depends { name: "MediaPlayer" } }

    Group {
        qbs.install: true
        fileTagsFilter: "dynamiclibrary"
    }
    cpp.includePaths: product.sourceDirectory
    cpp.defines: [ product.name.toUpperCase() + "_LIBRARY", ]
    Export {
        cpp.includePaths: product.sourceDirectory
        cpp.defines: [ product.name.toUpperCase() + "_LIBRARY", ]
    }
    <...>
}

MediaPlayer.h

#include "MediaPlayer_global.h"
#include "MediaPlayerInterface.h"

class MEDIAPLAYERSHARED_EXPORT MediaPlayer : public QWidget, public MediaPlayerInterface
{
    Q_OBJECT
    Q_INTERFACES(MediaPlayerInterface)
    <...>
}

ImagePlayer.h

#include "../mediaplayer/MediaPlayer.h"

class ImagePlayer : public MediaPlayer
{
    Q_OBJECT
    Q_INTERFACES(MediaPlayerInterface)
    Q_PLUGIN_METADATA(IID "org.geeksoft.qt.MediaPlayerInterface")
    <...>
}

But... I got a very unclear error result (it's ImagePlayer.dll linkage stage):

ImagePlayer.cpp.obj: unresolved external symbol "public: static struct QMetaObject const MediaPlayer::staticMetaObject" (?staticMetaObject@MediaPlayer@@2UQMetaObject@@B)

moc_ImagePlayer.cpp.obj: unresolved external symbol "public: static struct QMetaObject const MediaPlayer::staticMetaObject" (?staticMetaObject@MediaPlayer@@2UQMetaObject@@B)

Does anybody know what have gone wrong?

This part looks suspicious:

Export {
    // ...
    cpp.defines: [ product.name.toUpperCase() + "_LIBRARY", ]
}

It is unlikely that you really want to export this define, as it probably controls the value of some EXPORT preprocessor token in one of the library's header files (I can't say for sure, because I don't know your project). Just remove this line from the Export item.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM