Results 1 to 12 of 12

Thread: Plugin can load or not depending on whether my app is launched from Qt Creator or not

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2010
    Posts
    319
    Thanks
    1
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Plugin can load or not depending on whether my app is launched from Qt Creator or not

    Hi, I am having an unexplained behaviour using Qt 4.7.3 and Qt Creator 2.2.1 on Windows 7 (everything works fine on Ubuntu 10.10 and Mac OS X 10.6 using the same versions of Qt and Qt Creator).

    Basically, my application relies on various plugins being loaded upon starting my application. Now, for some weird reason, there is one out of 10 plugins that doesn't load when running my application from outside Qt Creator while if I start my application from within Qt Creator, then the plugin loads fine! This is the case whether I build a debug or release version of my application.

    As I said, everything works fine on Linux and Mac OS X, so I am really puzzled as why that particular plugin doesn't load. Why that plugin?!

    I know it might be a very long shot, but is there something trivial that I might have overlooked?

    Here is some code that I use (before actually loading the plugin) to retrieve some information about the plugin itself:

    Qt Code:
    1. PluginInfo Plugin::info(const QString &pPluginFileName)
    2. {
    3. // Return the information associated to the plugin
    4.  
    5. PluginInfo pluginInfo;
    6.  
    7. typedef PluginInfo (*PluginInfoFunc)();
    8.  
    9. PluginInfoFunc pluginInfoFunc = (PluginInfoFunc) QLibrary::resolve(pPluginFileName,
    10. QString(name(pPluginFileName)+"PluginInfo").toLatin1().constData());
    11.  
    12. if (pluginInfoFunc)
    13. // The plugin information function was found, so we can extract the
    14. // information we are after
    15.  
    16. pluginInfo = pluginInfoFunc();
    17. else
    18. {
    19. // The plugin information funciton couldn't be found which means that
    20. // we are not dealing with an OpenCOR plugin
    21.  
    22. pluginInfo.type = PluginInfo::Undefined;
    23.  
    24. if (!name(pPluginFileName).compare("CellMLModelRepository")) {
    25. QLibrary lib(pPluginFileName);
    26.  
    27. if (lib.load())
    28. QMessageBox::information(0, QString("Info"), "Can load...");
    29. else
    30. QMessageBox::information(0, QString("Info"), QString("Can NOT load... [%1 | %2]").arg(pPluginFileName,
    31. QFileInfo(pPluginFileName).exists()?"YES":"NO"));
    32. }
    33. }
    To copy to clipboard, switch view to plain text mode 
    So, what happens is that I am trying to resolve a function which should be in my plugin. In all cases, it works but for that CellMLModelRepository plugin of mine. Having added some debug code, if the function cannot be found, I try to load the plugin using QLibrary which here fails for my CellMLModelRepository plugin even though QFile::exists() does report that the file exists...

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Plugin can load or not depending on whether my app is launched from Qt Creator or

    Have you tried to output QLibary::errorString() ?
    This helps alot in tracking down such things :-)

    Maybe the plugin is not found at all, or some environment stuff (like QT_PLUGIN_PATH) is not set?

    HTH

  3. #3
    Join Date
    Mar 2010
    Posts
    319
    Thanks
    1
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Plugin can load or not depending on whether my app is launched from Qt Creator or

    Yes, indeed... However, QLibrary::errorString() only tells me that "the specified module could not be found". Yet, QFile::exists() tells me that my plugin does exist... and as mentioned in my original message, it works fine from within Qt Creator. As for QT_PLUGIN_PATH, I will have a look (didn't know about that one), but still I can't understand why my other plugins would load fine since they are in the exact same directory...

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Plugin can load or not depending on whether my app is launched from Qt Creator or

    Your library is failing to load because either:
    1. The library file itself does not exist.
    2. The library file depends on something that cannot be found when the environment is not being controlled by Qt Creator.
    3. The library file exists but is not a dynamically loadable library.

    If you are saying that 1 does not apply then my money is on option 2. Given that you are afflicted with Windows then the problem is that whatever you are depending on is not in the system PATH. If it runs in the IDE then this quite likely a Qt library, but it could anything else you have added to the IDE run-time PATH.

Similar Threads

  1. QPluginLoader not load plugin
    By Thyago.celler in forum Qt Programming
    Replies: 9
    Last Post: 20th May 2011, 19:01
  2. QPluginloader load plugin from RAM
    By meCHAoT in forum Qt Programming
    Replies: 3
    Last Post: 3rd February 2011, 17:23
  3. Qt Creator doesn't load nested plugin
    By skepticalgeek in forum Qt Tools
    Replies: 0
    Last Post: 9th January 2010, 21:10
  4. Driver loaded only when launched from Creator
    By vieraci in forum Qt Tools
    Replies: 0
    Last Post: 16th September 2009, 02:56

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.