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 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的更多相关文章
- 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++中,有时候需要在不同文件中使用同一个变量.对于这类变量如果处理不当,很 ...
随机推荐
- php魔术变量和13个PHP魔术函数
PHP魔术变量确切地说是PHP魔术常量,不过很多常量都是由不同的扩展库定义的,只有在加载了这些扩展库时才会出现,或者动态加载后,或者在编译时已经包括进去了.比如说__LINE__放在不同的地方是显示不 ...
- php 7 新特性整理小结
php 7 比php 5 性能提升了很多,php 7 新特性主要表现在:1.变量存储字节减小,减少内存占用,提升变量操作速度:2.改善数组结构,数组元素和hash映射表被分配在同一块内存里,降低了内存 ...
- coocs2d-html5在使用cocoseditor时调用设备的accelerometer来使用重力感应
在使用大牛touchsnow开发的插件cocoseditor开发游戏时遇到了一些问题,然后就试着解决.近期想试下coocs2d-html5是否能使用重力感应,发现是能够的.只是这个仅仅能在移动真机上測 ...
- python中base64编码与解码
在python3中用base64进行编码和解码的时候特别注意: 题目要求: 准备一张.jpg图片,比如:mm.jpg,读取图片数据并通过b85encode加密之后写入到新文件mm.txt文件中,然后读 ...
- 小程序 input 键盘弹出时样式遮盖问题
设置cursor-spacing,具体可参考官方文档,代码如下: <input type='text' bindinput="bindKeyInput" placehold ...
- RN-ios模拟器上调出中文输入法
react-native 项目:在ios模拟器上需要拼写汉字,步骤是, 1.在模拟器的设置-通用-语言与地区-iphone语言设置为:简体中文 2.模拟器的 Hardware-Keyboard-勾选下 ...
- w97常用功能代码
1,onclick中添加日期控件 2,onpicked事件即是点击控件后触发的事件 3,dp.cal.getNewDateStr()即是点击到的日期字符串 <script> functio ...
- spark.yarn.jar和spark.yarn.archive的使用
启动Spark任务时,在没有配置spark.yarn.archive或者spark.yarn.jars时, 会看到不停地上传jar非常耗时:使用spark.yarn.archive可以大大地减少任务的 ...
- DLNg[结构化ML项目]第二周迁移学习+多任务学习
1.迁移学习 比如要训练一个放射科图片识别系统,但是图片非常少,那么可以先在有大量其他图片的训练集上进行训练,比如猫狗植物等的图片,这样训练好模型之后就可以转移到放射科图片上,模型已经从其他图片中学习 ...
- [LeetCode] 577. Employee Bonus_Easy tag: SQL
Select all employee's name and bonus whose bonus is < 1000. Table:Employee +-------+--------+---- ...