zoukankan      html  css  js  c++  java
  • multiple definition of qt_plugin_query_metadata

    dustije 

    I have a project with several plugins i want to compile into one library. I get the error:
    @./debugmoc_stringoperationsplugin.o: In function qt_plugin_query_metadata': C:...ARGS-PluginsARGS-Plugins-build-Desktop_Qt_5_0_1_MinGW_32bit-Debug/debug/moc_stringoperationsplugin.cpp:153: multiple definition ofqt_plugin_query_metadata'
    ./debugmoc_tplugin.o:C:...ARGS-PluginsARGS-Plugins-build-Desktop_Qt_5_0_1_MinGW_32bit-Debug/debug/moc_tplugin.cpp:153: first defined here
    ./debugmoc_stringoperationsplugin.o: In function qt_plugin_instance': C:...ARGS-PluginsARGS-Plugins-build-Desktop_Qt_5_0_1_MinGW_32bit-Debug/debug/moc_stringoperationsplugin.cpp:153: multiple definition ofqt_plugin_instance'
    ./debugmoc_tplugin.o:C:...ARGS-PluginsARGS-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.

     
     
    lgeyer 

    [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.

  • 相关阅读:
    .net C# 利用Session防重复点击防重复提交
    子报表修改后需要重新导入,0.00显示.00的调整方法
    svn错误 svnserve.conf:12: Option expected解决办法
    mysql远程访问 登录ERROR 1130: is not allowed to connect to this MySQL server解决办法
    phpmyadmin新加用户登陆不了,测试解决方案。
    自己封装的php Curl并发处理,欢迎提出问题优化。
    js和php计算图片自适应宽高算法实现
    jquery获取浏览器宽高
    swftools中的pdf2swf转换Error overflow ID 65535 解决办法
    php 根据ip获取城市以及网络运营商名称(利用qqwry.dat)
  • 原文地址:https://www.cnblogs.com/senior-engineer/p/9342240.html
Copyright © 2011-2022 走看看