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. Unable to load qodbc driver not loaded
QtWS25 Last Chance

Unable to load qodbc driver not loaded

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 4.7k 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.
  • D Offline
    D Offline
    durgeshK
    wrote on last edited by
    #1

    Hi All,

    We are trying to create a DLL in C++(VS2005) using some of the Qt4.3.3 functionality(QtCore and QtSql). When i try to access this DLL from other C++ projects, its giving an error saying "Unable to load qodbc".

    In Normal Qt application , we can use addLibrayPath to add the plugins related to database and image, but how can we do this in a DLL project.

    Thanks & Regards,
    durgesh

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #2

      This is a core problem when you use Qt in dlls and use those dlls from non qt binaries. Some Qt functions require a Q(Core)Application instance.

      You could load a plug-in "by hand". It's a bit tricky...

      @
      QLibrary lib(QLatin1String("qtaccessiblewidgets4"));
      if(lib.load())
      {
      QtPluginInstanceFunction pInstanceFct = 0;
      QObject* pAccPlugin = 0;
      pInstanceFct = (QtPluginInstanceFunction)lib.resolve("qt_plugin_instance");

              if(0 != pInstanceFct)
              {
                  qRegisterStaticPluginInstanceFunction(pInstanceFct);
                  bLoaded = true;
              }
          }
      

      @

      it should work with most plug-ins :-) They just have to be found by the path.

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • D Offline
        D Offline
        durgeshK
        wrote on last edited by
        #3

        @Gerolf, Since i am using Qt4.3.3, i can't find some of the keywords like "qRegisterStaticPluginInstanceFunction" etc in my version.

        i just used the following in the dll function

        QLibrary lib(QLatin1String("C:\Qt\4.3.3\plugins\sqldrivers\qsqlodbcd4.dll"));
        if(lib.load())
        {
        lib.resolve("qt_plugin_instance");
        }
        else
        {
        MessageBoxA(NULL,"Unable to load qodbc","Error",1);
        exit(-5);
        }

        Now since i am not getting any MessageBox, i assume that i was able to load the plugin library. But again i am using this dll in another C++ console application, i am getting the error QODBC Driver not loaded.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          durgeshK
          wrote on last edited by
          #4

          Sorry for the above code the Code is as follow :

          @QLibrary lib(QLatin1String("C:\Qt\4.3.3\plugins\sqldrivers\qsqlodbcd4.dll"));
          if(lib.load())
          {
          lib.resolve("qt_plugin_instance");
          }
          else
          {
          MessageBoxA(NULL,"Unable to load qodbc","Error",1);
          exit(-5);
          }@

          1 Reply Last reply
          0
          • G Offline
            G Offline
            giesbert
            wrote on last edited by
            #5

            You only loaded a library, but did not add the plug in.

            @
            typedef QObject *(*QtPluginInstanceFunction)();
            @

            can be found in qplugin.h. And without a call to qRegisterStaticPluginInstanceFunction the plugin is not registered in the global plugin cache. Without registration, it's not usable.

            Nokia Certified Qt Specialist.
            Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

            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