Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9141529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:39:24+00:00 2026-06-17T09:39:24+00:00

I have successfully compiled the MySQL drivers, but I cannot force Qt to load

  • 0

I have successfully compiled the MySQL drivers, but I cannot force Qt to load them.

What should be said in the beginning Iv got ODBC and SQLite drivers with the package (after installing Qt) and they are not detected either.

In *C:\Qt\4.8.0\plugins\sqldrivers* Iv got:

qsqlite4.dll

qsqlite4.lib

qsqlited4.dll

qsqlited4.lib

qsqlmysql4.dll

qsqlmysql4.lib

qsqlmysqld4.dll

qsqlmysqld4.lib

qsqlodbc4.dll

qsqlodbc4.lib

qsqlodbcd4.dll

qsqlodbcd4.lib

qsqlpsql4.dll

qsqlpsql4.lib

qsqlpsqld4.dll

qsqlpsqld4.lib

The qsqlmysql*.* files I have also put in:

C:\Qt\4.8.0\bin

APPLICATION\

APPLICATION\Debug\

APPLICATION\Release\

APPLICATION\sqldrivers\

Of course Iv got QtSql*.dll also in place.

Iv got .pro properly configured:

QT += core gui network sql

And I’m running this code:

#include <QSqlRecord>
#include <QSqlError>

QLibrary mysqllib("qsqlmysqld4.dll");
mysqllib.load();
auto t1 = mysqllib.isLoaded();
qDebug()<<"my library loaded"<<mysqllib.isLoaded();

QPluginLoader plug("qsqlmysqld4.dll");
plug.load();
auto t2 = plug.isLoaded();
qDebug()<<"mysql plugin is loaded"<<plug.isLoaded();

ui->textEditContent->append( "--SQL DRIVERS SUPPORTED:--\n" );
FOREACH( auto driver, QSqlDatabase::drivers() )
    ui->textEditContent->append( "  " + driver + "\n" );

QLibrary and QPluginLoader returns true. And QSqlDatabase::drivers() is empty.
What I’m doing wrong? None of the drivers in C:\Qt\4.8.0\plugins\sqldrivers are seen by Qt.
Iv compiled Qt and SQL drivers with same compiler (MSVC2010), without errors. I’m running my code for several months. The task was to add MySQL support.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:39:25+00:00Added an answer on June 17, 2026 at 9:39 am

    Problem solved!
    I have modified the code, now it looks like this:

    #include <QSqlRecord>
    #include <QSqlError>    
    
    QStringList liblist;
    liblist.push_back("c:/Qt/4.8.0/plugins/");
    liblist.push_back("c:/Qt/4.8.0/bin/");
    QCoreApplication::setLibraryPaths(liblist);
    
    QLibrary mysqllib("qsqlmysqld4.dll");
    mysqllib.load();
    auto t1 = mysqllib.isLoaded();
    qDebug()<<"my library loaded"<<mysqllib.isLoaded();
    
    QPluginLoader plug("qsqlmysqld4.dll");
    plug.load();
    auto t2 = plug.isLoaded();
    qDebug()<<"mysql plugin is loaded"<<plug.isLoaded();
    
    ui->textEditContent->append( "--SQL DRIVERS SUPPORTED:--\n" );
    FOREACH( auto driver, QSqlDatabase::drivers() )
        ui->textEditContent->append( "  " + driver + "\n" );
    

    It seems that even if Qt have paths to it’s own folder you need to specify them before loading the drivers.
    You can do this by adding those lines:

    QStringList liblist;
    liblist.push_back("c:/Qt/4.8.0/plugins/");
    liblist.push_back("c:/Qt/4.8.0/bin/");
    QCoreApplication::setLibraryPaths(liblist);
    

    If you want to include those drivers into your application folder as I do you create folder ‘sqldrivers’ in root of your application and add path to this root.
    So we have libmysql.dll and qsqlmysql.dll in:

    X:\APPLICATION\sqldrivers\

    and code looks like this:

    QStringList liblist;
    liblist.push_back(QDir::currentPath()); // Qt always looks for those drivers in <LIB_FOLDER_SPECIFIED>/sqldrivers/
    //liblist.push_back("e:/Qt/4.8.0/bin/");
    //liblist.push_back("e:/Qt/4.8.0/plugins/");
    QCoreApplication::setLibraryPaths(liblist);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have successfully compiled PHP 5.4.9 on Cygwin, but now I am unable to
I have successfully compiled my code, but it says this: Note: You can also
I have successfully compiled lua in my mac. It works. It runs. Now, I
I have successfully compiled the FFMPEG library to android using NDK. I want to
I'm trying to create a NuGet package from a .csproj. I have successfully compiled
I have successfully upgraded an MFC application which was compiled with an old version
I have my program written in C++ and it is can be successfully compiled
I have compiled a simple win32 app successfully with bc++ (2 lines excerpt only):
I have successfully implemented a mysql server as a JDBCRealm for authentication in Tomcat
I recently got MySQL compiled and working on Cygwin, and got a simple test

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.