I have a project with several plugins i want to compile into one library. I get the error:
@./debug\moc_stringoperationsplugin.o: In function qt_plugin_query_metadata': C:\...\ARGS-Plugins\ARGS-Plugins-build-Desktop_Qt_5_0_1_MinGW_32bit-Debug/debug/moc_stringoperationsplugin.cpp:153: multiple definition ofqt_plugin_query_metadata'
./debug\moc_tplugin.o:C:...\ARGS-Plugins\ARGS-Plugins-build-Desktop_Qt_5_0_1_MinGW_32bit-Debug/debug/moc_tplugin.cpp:153: first defined here
./debug\moc_stringoperationsplugin.o: In function qt_plugin_instance': C:\...\ARGS-Plugins\ARGS-Plugins-build-Desktop_Qt_5_0_1_MinGW_32bit-Debug/debug/moc_stringoperationsplugin.cpp:153: multiple definition ofqt_plugin_instance'
./debug\moc_tplugin.o:C:...\ARGS-Plugins\ARGS-Plugins-build-Desktop_Qt_5_0_1_MinGW_32bit-Debug/debug/moc_tplugin.cpp:153: first defined here@
Do i have to have a project for every single plugin or is it possible to have several plugins in one library? If it's possible to have several plugins in one library, what else could cause this error? I could not find a single helpful post online so i think this problem is very rare.
I'll post code if someone thinks that will be necessary but i hope to get a general answer to what could cause this error message.
Thanks in advance!

Edit: Quick question: does the IID in the "Q_PLUGIN_METADATA(IID "reversed.url")" need to be unique, e.g. does every plugin needs its own IID or should it be the same for every plugin? I couldn't find information regarding this.

 
 

[quote] Q_PLUGIN_METADATA(...)
This macro is being used to declare meta data that is part of a plugin that instantiates this object.
The macro needs to declare the IID of the interface implemented through the object, and reference a file containing the meta data for the plugin.
There should be exactly one occurrence of this macro in the source code for a Qt plugin.[/quote]

You can't have multiple Q_PLUGIN_METADATA definitions per plugin (for technical reasons, the plugin metadata is placed in a special region of the binary so the metadata can be fetched without dlopen()'ening the library and for logical reasons, as there has to be a single root object which is instantiated on load), but you can have multiple classes implementing various interfaces.

@
class PluginA : public QObject, public InterfaceA
{
Q_OBJECT
Q_INTERFACES(InterfaceA)
}

class PluginB : public QObject, public InterfaceB
{
Q_OBJECT
Q_INTERFACES(InterfaceB)
}

class PluginCollection : public QObject, public PluginCollectionInterface
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "PluginCollectionInterface")

public:
QList<QObject*> plugins() { return QList<QObject*>{new PluginA, new PluginB}; }

// or

QList<QString> plugins() { ... }
QObject *create(const QString &plugin) { ... };

}
@
Brain to terminal.

multiple definition of qt_plugin_query_metadata的更多相关文章

  1. multiple definition of `err_sys' 《UNIX环境高级编程》

    本文地址:http://www.cnblogs.com/yhLinux/p/4079930.html 问题描述: [点击此处直接看解决方案] 在练习<UNIX环境高级编程>APUE程序清单 ...

  2. gcc: multiple definition of [转]

    /home/tace/openav/source/SeamlessMessage/CPaoFlt.o: In function `CPaoFlt::get_m_strPrmair() const':C ...

  3. 链接错误:multiple definition of 'xxx' 问题解决及其原理

    内容借鉴 于CSDN炸鸡叔 错因 截图: “multiple definition of  'head' ” “multiple definition of  'tail' ” 解决过程: 1.首先要 ...

  4. multiple definition of XXX情况分析

    近日在写代码,各个.cpp源文件编译时没有问题,将*.o进行链接时,出现了许多multiple definition of XXX的链接错误.于是在网上搜索了一番,结合自己的代码包含逻辑,最终发现了问 ...

  5. [err]multiple definition of `***'

    err CMakeFiles/dsm.dir/src/main_stateEstimation.cpp.o: In function `align_mean(cv::Mat, cv::Rect_< ...

  6. QT编译错误: multiple definition of `qMain(int, char**)'

    QT使用过程中来回添加修改代码,结果出现了编译错误:error: multiple definition of `qMain(int, char**)' 一直看我的源文件是都哪里有错误,最后发现是在p ...

  7. qt用mingw编译时报错 multiple definition of

    网上相关回答不少,但过于简单,这里做一下记录. qt用mingw编译程序时报“multiple definition of …”这个错误,错误信息大概是如下图所示: 1 2 3 首先,检查自己的程序是 ...

  8. 解决 multiple definition of

    总结了解决multiple definition of的方法: 问题原因:    当多个文件包含同一个头文件时,并且你的.H里面没有加上条件编译#ifndef TEST_H#define TEST_H ...

  9. C++ "multiple definition of .. first defined here"

    C++ "multiple definition of .. first defined here" 在C++中,有时候需要在不同文件中使用同一个变量.对于这类变量如果处理不当,很 ...

随机推荐

  1. 电脑出现 flash update failed 解决方法

    笔记本电脑过了一个周末打开时出现以上问题,每次都进入这个界面 解决方法: 拆机,插拨一下内存条,硬盘,就启动了

  2. 2 jmeter常用功能介绍-测试计划、线程组

    1.测试计划测试用来描述一个性能测试,所有内容都是基于这个测试计划的. (1)User Defined Variables:设置用户全局变量.一般添加一些系统常用的配置.如果测试过程中想切换环境,切换 ...

  3. 列表选择框:wxSingleChoiceDialog

    wxSingleChoiceDialog(wxWindow* parent, const wxString& message, const wxString& caption, int ...

  4. Spring boot 整合hive-jdbc导致无法启动的问题

    使用Spring boot整合Hive,在启动Spring boot项目时,报出异常: 经过排查,是maven的包冲突引起的,具体做法,排除:jetty-all.hive-shims依赖包.对应的po ...

  5. [django]restfulapi请求规范

    http://www.ruanyifeng.com/blog/2014/05/restful_api.html 方法及作用: GET(SELECT) :从服务器取出资源(一项或多项). POST(CR ...

  6. word2vec 评测 sg=0 sg=1 size=100 window=3

    1.评价sg=0与sg=1的区别    结果原文:sg_difference.txt sg=0     sg=1 绑定                         1 关联            ...

  7. MySQL--8MySQL存储过程小结

    CURD: 就是对数据表进行插入更新删除查找的操作. 预编译:第一次会分析语法是否正确,编译成可识别的命令.然后存在内存中,以后再调用就省去了这两步,效率变高. 第一点:在存储过程内可以写控制语句,可 ...

  8. Python Shell 中敲击方向键显示「^[[C^[[D],问题解决

    碰到问题后,在网上搜索. 有帖子建议:yum install -y ncurses-devel,我这个2.7.13版本的在Linux下不行.估计是解决python3.x的方案. 尝试网上建议的,装了 ...

  9. WCF&AppFabric :异常消息: 内存入口检查失败

    bug描述 发件人信息: System.ServiceModel.ServiceHostingEnvironment+HostingManager/31242459 异常: System.Servic ...

  10. python快速开发Web之Django

    以前写测试框架,要么是纯python代码驱动的,要么是WinForm界面的框架,多人操作并不适合. 就想用python写个Web版的,于是想到了Web快速开发的框架Flask和Django两个 个人觉 ...