Windows: Qt Driver Available But Not Loaded.



  • I made a previous post about my application running on foreign machines. I'm making this post in the general and desktop section because I believe it's no longer a dependency/deployment issue.

    My application uses the OCI SQL plugin to connect to an oracle database on the backend. I am able to connect to the database using the plugin on my local machine, however the same can't be said for the deployment folder.

    Application Details:
    -Built with mingw32-bit
    -Built the plugin using mingw32-bit following this post

    Here's what I've done to my deployment (and release) directory:

    • Created a 'sqldrivers' directory for my oci plugin. Copied qsqloci.dll into directory.
    • Created a 'platforms' directory for the qwindow.dll
    • Copied all corresponding .dlls from the mingw32 into my deployment directory.
    • Tried just about every permutation of including the plugin-related .dlls in said directories...

    Here is my current set up:

    alt text
    alt text
    *I know the directory name is off in the screenshot when it was taken.

    Upon loading the client on the foreign machine, I check to see if the plugins are available. It appears that they are:
    alt text

    Then I try connecting to the database and it claims the driver is not loaded even though it is available..
    alt text

    At this point, I thought I had a more definitive problem because the driver was available, but it just wasn't being loaded. From there I google searched for "Qt sql driver available but not loaded". I found some results that provided solutions I had already accounted for such as the Loading Plugins Documention and making sure the plugin is located under sqldrivers. However, I did find one result which mentioned using QPluginLoader and QLibrary to explicity load the libraries so I tried that.

    I tweaked my code to update the error/output messages on the labels since this was being run in release mode.

    QLibrary mylib("sqldrivers/oci.dll");
    mylib.load();
    ui->input_username->setText("library loaded? " + toQString(mylib.isLoaded()));
    
    QPluginLoader plug("sqldrivers/qsqloci.dll");
    plug.load();
    ui->label_error_message->setText("oci plugin loaded? " + toQString(plug.isLoaded()));
    

    This raises a question. What is the difference between a plugin and a library when I'm using QPluginLoader/QLibrary? From my understanding, the actual plugin I built is stored in 'qsqloci.dll' which is a dynamically linked library. Do I also need to include the .lib file somewhere within my deployment directory?

    After booting up the application it appears as though both the plugin and library were loaded successfully.
    alt text

    However, once I try connecting I get super helpful error message...
    alt text

    It looks like some others have had the same issue, but following their suggestions haven't seemed to get it working.

    One important discovery I've made is that my application is trying to reference my 'C:\oracle' directory during runtime. If I remove that directory it fails to load the drivers on my Local Machine. Correct me if I'm wrong, but I thought by building the plugin dynamically it meant that I wouldn't need to have oracle client installed on the foreign computer because all of the corresponding information has been compiled into 'qsqloci.dll'. For my final application, installing the oracle client (or instantclient) on foreign computers is not an option so I will do whatever to avoid that. What steps do I need to take so that my application is NOT dependent on files located in 'C:\oracle' during runtime? Here is my makefile.release is if it helps.

    Other steps taken:
    -Copied oci-related .dlls to system32
    -Set the path evirnoment variable to oracle directory
    -Rebuilt the plugin several times.
    -Copied all my Qt Dirs and Oracle dirs to foreign computer; still could not connect.

    Again, all of this works fine when run on my local machine so I'm confident the .dll was compiled successfully. The only instance when fails to connect on my local machine is when I remove the 'C:\oracle' directory. It even works from the deployment directory on my flashdrive if it's plugged into my local machine, but it just doesn't want to connect on other computers. I have tried copying all directories to a different computer, setting the environment variables and am still running into the same problem.


  • Moderators

    @Pratted Well first thing I noticed is your directories are not organized correctly. This is why your plugins aren't loading correctly (probably).

    By default you need them like:

    <root of your app>
       plugins/
          images/
          platforms/
          sqldrivers/
       *.exe
       *.dll
    

    A way around that is to load the plugins manually, specify the path in code, or use a qt.conf in your binary directory with a path to your base plugins dir, like so:

    [Paths]
    Plugins = .
    

    When you say it isn't working what is happening? What kind of errors are thrown from the SQL engine?

    As for your oracle specific questions like client loading on the target system I can't answer as all my SQL stuff has been with MySQL, SQLite, Postgres, etc. Never used Oracle.

    Oh and don't copy your dlls to system32. That is definitely bad form and not necessary.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.