Qt插件:从qmake到qbs.链接错误



我有一个由两个产品组成的 .pro 项目:

player.pro

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

madiaplayer.pro - DLL 库

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

imageplayer.pro - Qt插件

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

它工作正常。但现在我需要 qbs 版本。


我写的是这样的:

播放器.qbs

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

媒体播放器.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", ]
    }
    <...>
}

媒体播放器.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")
    <...>
}

但。。。我得到了一个非常不清楚的错误结果(这是ImagePlayer.dll链接阶段(:

ImagePlayer.cpp.obj:未解析的外部符号"public: static struct QMetaObject const MediaPlayer::staticMetaObject" (?staticMetaObject@MediaPlayer@@2UQMetaObject@@B(

moc_ImagePlayer.cpp.obj:未解析的外部符号"public: static struct QMetaObject const MediaPlayer::staticMetaObject" (?staticMetaObject@MediaPlayer@@2UQMetaObject@@B(

有谁知道出了什么问题?

这部分看起来很可疑:

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

您不太可能真的想要导出此定义,因为它可能控制库头文件中某个 EXPORT 预处理器令牌的值(我不能肯定地说,因为我不知道您的项目(。只需从"导出"项中删除此行即可。

相关内容

  • 没有找到相关文章

最新更新