Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Unable to load qodbc driver not loaded

    General and Desktop
    2
    5
    4478
    Loading More Posts
    • 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
      durgeshK last edited by

      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 Reply Quote 0
      • G
        giesbert last edited by

        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 Reply Quote 0
        • D
          durgeshK last edited by

          @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 Reply Quote 0
          • D
            durgeshK last edited by

            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 Reply Quote 0
            • G
              giesbert last edited by

              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 Reply Quote 0
              • First post
                Last post