博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
multiple definition of qt_plugin_query_metadata
阅读量:6219 次
发布时间:2019-06-21

本文共 2788 字,大约阅读时间需要 9 分钟。

 

 

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}; }

// orQList
plugins() { ... }QObject *create(const QString &plugin) { ... };

}

@
Brain to terminal.

转载地址:http://fvoja.baihongyu.com/

你可能感兴趣的文章
第九周学习进度报告
查看>>
Shell - 简明Shell入门05 - 条件语句(Case)
查看>>
VS2013 自动为类文件添加头注释
查看>>
nodejs使用fetch获取WebAPI
查看>>
Linux 常用命令记录
查看>>
线性代数与矩阵论 习题 1.2.2
查看>>
1. Two Sum
查看>>
portal单点登录的原理与实现还有ESB
查看>>
当页面加载完成时,JQ触发添加页面的元素的事件触发不了。。
查看>>
索尼Sony ATI显卡驱动 Win7 Win8 Win8.1 视频黑屏 解决方法
查看>>
中介者模式(Mediator Pattern)
查看>>
vim 简单笔记
查看>>
js功能实现top轮播图
查看>>
IOS系列swift语言之课时四
查看>>
Luogu P3935 Calculating
查看>>
passive的作用和原理
查看>>
projecteuler Summation of primes
查看>>
2018百度之星资格赛A B F
查看>>
App 卸载记录
查看>>
Chisel3 - util - BitPat
查看>>