Results 1 to 2 of 2

Thread: Qt Plugins Error

  1. #1
    Join Date
    Aug 2007
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Qt Plugins Error

    Hello,

    I was wondering if anyone could help me out with a strange error I get working with plugins. I'm building a plugin based application and I've successfully loaded plugins and used them in my application (similar to the plug and paint example). I'm trying to add another plugin which links to a 3rd party library (GDCM - GNU Dicom Library). I've modified the .pro file to link to these libraries (using LIBS = ...) and the plugin compiles fine and loads fine in my application. The code in my main application loads plugins like this:

    void MainWindow::loadPlugins(){
    //Find the plugins Directory
    //QDir pluginsDir = QDir(qApp->applicationDirPath(),"",QDir::Reversed);
    QDir pluginsDir = QDir(qApp->applicationDirPath(),"");

    #if defined(Q_OS_WIN)
    if (pluginsDir.dirName().toLower() == "debug" || pluginsDir.dirName().toLower() == "release")
    pluginsDir.cdUp();
    #elif defined(Q_OS_MAC)
    if (pluginsDir.dirName() == "MacOS") {
    pluginsDir.cdUp();
    pluginsDir.cdUp();
    pluginsDir.cdUp();
    }
    #endif
    pluginsDir.cd("plugins");

    foreach (QString fileName, pluginsDir.entryList(QDir::Files)) {
    QPluginLoader* pLoader = new QPluginLoader(pluginsDir.absoluteFilePath(fileName ));
    printf(fileName.toAscii().data());
    if (pLoader){
    QObject *plugin = pLoader->instance();
    printf("1");
    if (plugin) {
    printf("2\n");

    So as it loads the plugins, it prints the name of the file, then '1', then '2'

    However, when I add code that uses the 3rd party library to my plugin, The plugin still compiles with no complaints, but it won't load as a plugin in my application. It loads the other plugins fine, but it only prints '1' (not '2') when loading the modified plugin. So, pLoader->instance() now returns 0 after adding in the code from the 3rd party library.

    Does anyone have any idea as to what might be going on??

    Thanks,

    Nathan

    PS - One possible explaination could be as described here:
    "When you build the plugin, the linker won't complaint about missing symbols as it is a dynamic library pending to be linked on runtime. Later, when the plugin host (either designer or a QUiLoader based app) tries to load it and fails, it does not complain at all neither. Just that the plugin won't be available but no error message is displayed."
    -- http://www.iua.upf.edu/~dgarcia/Codd...otloading.html

    But I tried compiling "cl plugintest.cpp /link qvol_dicomdoc.lib" and got no error

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Qt Plugins Error

    Hi

    Yes, the application of yours must link to that 3rd party library. By the way, I suppose you would get the reason (a linkage error) if you turned the plugin temporarily as static.
    J-P Nurmi

Similar Threads

  1. Installation on Fedora Core 4
    By jcr in forum Installation and Deployment
    Replies: 3
    Last Post: 29th January 2009, 01:34
  2. qt 4.2.2 install on aix
    By try to remember in forum Installation and Deployment
    Replies: 2
    Last Post: 28th March 2007, 12:19
  3. Qt-x11-commercial-src-4.2.0-snapshot-20060824 error
    By DevObject in forum Installation and Deployment
    Replies: 4
    Last Post: 24th August 2006, 23:31
  4. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 12:52
  5. Am I the only one with "make" error ?
    By probine in forum Installation and Deployment
    Replies: 1
    Last Post: 13th February 2006, 12:54

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.