Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QPluginLoader cannot load a dll with MKL library calls
QtWS25 Last Chance

QPluginLoader cannot load a dll with MKL library calls

Scheduled Pinned Locked Moved General and Desktop
9 Posts 5 Posters 5.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    myfeng
    wrote on last edited by
    #1

    Hi All,

    I am trying to load my plug-in module like below:

    @
    QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
    QObject *plugin = loader.instance();
    @

    I found if the dll file doesn't make Intel MKL calls, it can be loaded; otherwise it cannot be loaded(plugin pointer is null). Does any one know reasons? or how to fix it? Thanks a lot.

    myfeng

    [EDIT: code formatting, please wrap in @-tags, Volker]

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Franzk
      wrote on last edited by
      #2

      Did you cast the plugin pointer to your plug-in interface?

      @QPluginLoader loader(filename);
      MyPlugin *plugin = qobject_cast<MyPlugin *>(loader.interface());
      if (plugin) {
      // ...
      }
      //...
      @

      "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • D Offline
        D Offline
        DeVeL-2010
        wrote on last edited by
        #3

        Maybe some MKL dlls can't be found?
        Otherwise, please be more precise. What do you mean with "dll file doesn’t make Intel MKL calls". Will the MKL still loaded in this case?

        What says QPluginLoader::errorString()?

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          [quote author="Franzk" date="1298961225"]Did you cast the plugin pointer to your plug-in interface?

          @QPluginLoader loader(filename);
          MyPlugin *plugin = qobject_cast<MyPlugin *>(loader.interface());
          if (plugin) {
          // ...
          }
          //...
          @[/quote]

          This cannot work. If the instance pointer, which is of type QObject, is already null it cannot be casted to a QObject derived pointer. A null pointer always yields another null pointer if casted.

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • R Offline
            R Offline
            r2d3
            wrote on last edited by
            #5

            Hello,

            I think there is 2 solutions to this mkl DLL problem :

            place the DLL in the same directory as your .EXE so the OS will find it when it will search for it

            load the DLL manually (using QLibrary, QLibrary::load) BEFORE you load the plugin

            Regards.

            1 Reply Last reply
            0
            • G Offline
              G Offline
              goetz
              wrote on last edited by
              #6

              Good point, r2d3, "QLibrary":http://doc.qt.nokia.com/4.7/qlibrary.html should be the way to go (unless your DLL is actually a Qt plugin).

              QPluginLoader":http://doc.qt.nokia.com/4.7/qpluginloader.html is for Qt plugins only:

              bq. QPluginLoader provides access to a Qt plugin. A Qt plugin is stored in a shared library (a DLL) and offers these benefits over shared libraries accessed using QLibrary....

              http://www.catb.org/~esr/faqs/smart-questions.html

              1 Reply Last reply
              0
              • F Offline
                F Offline
                Franzk
                wrote on last edited by
                #7

                [quote author="Volker" date="1298987063"]If the instance pointer, which is of type QObject, is already null it cannot be casted to a QObject derived pointer.[/quote]My mistake there. I misread the post to say that the instance pointer was non-null, thereby assuming that there was some object casting to be done.

                "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

                http://www.catb.org/~esr/faqs/smart-questions.html

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  goetz
                  wrote on last edited by
                  #8

                  [quote author="Franzk" date="1299003220"]My mistake there. I misread the post to say that the instance pointer was non-null, thereby assuming that there was some object casting to be done.
                  [/quote]

                  No problem - that's the nice thing on Qt DevNet: There's almost always someone who does kind-of proof reading - and it saved some others from my own crap several times :-)

                  http://www.catb.org/~esr/faqs/smart-questions.html

                  1 Reply Last reply
                  0
                  • R Offline
                    R Offline
                    r2d3
                    wrote on last edited by
                    #9

                    A third solution is to change directory to the plugin directory as Windows is also searching for DLL in the current directory.

                    "Search Path Used by Windows to Locate a DLL":http://msdn.microsoft.com/en-us/library/7d83bc18(v=vs.80).aspx

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved