【发布时间】:2013-12-28 14:10:47
【问题描述】:
免责声明:在 Linux 上一切正常。在 Windows 上,我最近从 MinGW 更改为 MSVC2012,因为我无法正确读取 MP3(请参阅Make the WMF plugin compile with MinGW.)
在我的项目中,我有:
- 核心 (DLL)
- 另一个使用 Core 构建的 DLL
- 媒体播放器(Qt 应用,同时使用 DLL 和加载插件)
为了让我的项目跨平台,我还将 Windows 特定功能 (progress bar, thumbnail buttons) 提取到了第 3 方插件中。事实上,我正在开始编写一个插件管理器,它在运行时加载/卸载插件,无需重新启动应用程序,它工作正常。
但自从我切换到 MSVC 后,我无法再构建我的插件了。我正面临:
C4273: 'staticMetaObject' : 不一致的 dll 链接
我不知道如何继续...我有以下结构:
在 MainProject\Core\Interfaces 中
class MIAMCORE_LIBRARY MediaPlayerPluginInterface : public BasicPluginInterface
{
public:
virtual ~MediaPlayerPluginInterface() {}
virtual void setMediaPlayer(QWeakPointer<MediaPlayer>) = 0;
virtual bool providesView() const = 0;
virtual void toggleViews(QWidget *) {}
};
在 Plugin.h 中
class Minimode : public QWidget, public MediaPlayerPluginInterface
{
Q_OBJECT
Q_PLUGIN_METADATA(IID MediaPlayerPluginInterface_iid)
Q_INTERFACES(MediaPlayerPluginInterface)
private:
Ui::ConfigForm _ui;
QWeakPointer<MediaPlayer> _mediaPlayer;
bool _startMoving;
QPoint _pos, _globalPos;
public:
explicit Minimode();
virtual ~Minimode();
inline virtual QString name() const { return "Minimode"; }
inline virtual QString version() const { return "1.0"; }
inline virtual bool providesView() const { return true; }
virtual QWidget* configPage();
virtual void setMediaPlayer(QWeakPointer<MediaPlayer> mediaPlayer);
virtual void toggleViews(QWidget *view);
protected:
/** Redefined to be able to drag this widget on screen. */
void mouseMoveEvent(QMouseEvent *e);
/** Redefined to be able to drag this widget on screen. */
void mouseReleaseEvent(QMouseEvent *e);
void mousePressEvent(QMouseEvent *e);
private:
void applyColorToStandardIcon(QPushButton *button);
};
我的插件.pro
QT += widgets multimedia
TARGET = $$qtLibraryTarget(mini-mode)
TEMPLATE = lib
MiamPlayerBuildDirectory = C:\dev\Miam-Player\build\MiamPlayer
DEFINES += MINIMODE_MIAMPLUGIN
CONFIG += c++11
CONFIG(debug, debug|release) {
target.path = $$MiamPlayerBuildDirectory\debug\plugins
LIBS += -Ldebug -lMiamCore
}
INSTALLS += target
Miamcore_global.h
#ifndef MIAMCORE_GLOBAL_H
#define MIAMCORE_GLOBAL_H
#include <QtCore/QtGlobal>
#if defined(MIAMCORE_LIBRARY)
#undef MIAMCORE_LIBRARY
#define MIAMCORE_LIBRARY Q_DECL_EXPORT
#else
#define MIAMCORE_LIBRARY Q_DECL_IMPORT
#endif
#endif // MIAMCORE_GLOBAL_H
我尝试了宏 MIAMCORE_LIBRARY 和另一个 MINIMODE_PLUGIN 的各种排列,但它们都不起作用(在类和 Minimode 之间,但上面没有显示)。我应该在我的 *.pro 文件中添加特定的关键字吗?
【问题讨论】:
-
显示“MIAMCORE_LIBRARY”的定义,同时修正你的代码格式...
标签: c++ windows qt visual-c++ dll