multiple definition of qt_plugin_query_metadata
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 of
qt_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 of
qt_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的更多相关文章
- multiple definition of `err_sys' 《UNIX环境高级编程》
本文地址:http://www.cnblogs.com/yhLinux/p/4079930.html 问题描述: [点击此处直接看解决方案] 在练习<UNIX环境高级编程>APUE程序清单 ...
- gcc: multiple definition of [转]
/home/tace/openav/source/SeamlessMessage/CPaoFlt.o: In function `CPaoFlt::get_m_strPrmair() const':C ...
- 链接错误:multiple definition of 'xxx' 问题解决及其原理
内容借鉴 于CSDN炸鸡叔 错因 截图: “multiple definition of 'head' ” “multiple definition of 'tail' ” 解决过程: 1.首先要 ...
- multiple definition of XXX情况分析
近日在写代码,各个.cpp源文件编译时没有问题,将*.o进行链接时,出现了许多multiple definition of XXX的链接错误.于是在网上搜索了一番,结合自己的代码包含逻辑,最终发现了问 ...
- [err]multiple definition of `***'
err CMakeFiles/dsm.dir/src/main_stateEstimation.cpp.o: In function `align_mean(cv::Mat, cv::Rect_< ...
- QT编译错误: multiple definition of `qMain(int, char**)'
QT使用过程中来回添加修改代码,结果出现了编译错误:error: multiple definition of `qMain(int, char**)' 一直看我的源文件是都哪里有错误,最后发现是在p ...
- qt用mingw编译时报错 multiple definition of
网上相关回答不少,但过于简单,这里做一下记录. qt用mingw编译程序时报“multiple definition of …”这个错误,错误信息大概是如下图所示: 1 2 3 首先,检查自己的程序是 ...
- 解决 multiple definition of
总结了解决multiple definition of的方法: 问题原因: 当多个文件包含同一个头文件时,并且你的.H里面没有加上条件编译#ifndef TEST_H#define TEST_H ...
- C++ "multiple definition of .. first defined here"
C++ "multiple definition of .. first defined here" 在C++中,有时候需要在不同文件中使用同一个变量.对于这类变量如果处理不当,很 ...
随机推荐
- 帝国cms添加修改会员字段时字段名不能带数字,否则注册页会出现空白
这几天ytkah在整帝国cms会员模块,根据客户需求添加不同的字段,这个相对不难,可还是遇到了点问题.当时添加会员字段时,在字段名用数字“1”来代表第一次,如下图的字段名“1rwsdy” 但是添加以后 ...
- 火币网API文档——WebSocket API错误码
错误信息返回格式 { "id": "id generate by client", "status": "error", ...
- kafka3 本地目录结构以及在在zk上的znode
一 kafka本地目录结构 [root@hadoop ~]# cd /tmp/kafka-logs1 [root@hadoop kafka-logs1]# find . . ./.lock ./rec ...
- Mac charles 抓取https请求,安装证书后还是显示unknown
https://blog.csdn.net/qq_23114525/article/details/81460840 1. 配置证书 2. 设置钥匙串信任 3. 设置手机代理 端口号需要对应设置的端口 ...
- [py]super调用父类的方法---面向对象
super()用于调用父类方法 http://www.runoob.com/python/python-func-super.html super() 函数是用于调用父类(超类)的一个方法. clas ...
- SQL中查询前几条或者中间某几行数据limit
SELECT * FROM table LIMIT [offset,] rows | rows OFFSET offset 使用查询语句的时候,要返回前几条或者中间某几行数据,用Llimit 可 ...
- Python 类对象去重
注:set 对类对象去重,在于重写__eq__方法和__hash__方法,如果没有重写__hash__会导致People类对象不是可hash的 #!/usr/bin/env python # -*- ...
- 笔记:yum和apt-get的区别
rpm包和deb包是两种Linux系统下最常见的安装包格式,在安装一些软件或服务的时候免不了要和它们打交道. rpm包主要应用在RedHat系列包括 Fedora等发行版的Linux系统上, deb包 ...
- JavaScript-isFinite()判断是否数字有效
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...
- 关于django编码问题所导致的502错误
在使用django开发的时候,访问网站出现了502错误,次数也比较平繁 uwsgi+nginx+django 在命令行下提示如下错误 : File "/opt/apps/python3/li ...