我有一个由两种产品组成的 .pro 项目:
播放器.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", ]
}
<...>
}
图像播放器.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)
<...>
}
图像播放器.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)
有人知道出了什么问题吗?