Where is the SQL database plugin for ODBC (qsqlodbc.dll) in Qt 5.6 ?

It looks like the SQL database plugin for ODBC (qsqlodbc.dll) is missing from the standard Qt 5.6 installer for Windows you download from http://www.qt.io/download-open-source.

You’d expect to find it in C:\Qt\Qt5.6.0\5.6\msvc2015_64\plugins\sqldrivers\ where the sqlite, mysql and postgresql ones are found, but the ODBC plugin is not there.

The issue is known (see QTBUG-49420 and QTBUG-51390) but these bug reports are closed and it seems there will be no fix on a short term.

So here is how you build qsqlodbc.dll from source for Windows 64-bit with Visual Studio 2015, based on the instructions “How to Build the ODBC Plugin on Windows”.

First get the source package qt-everywhere-opensource-src-5.6.0.zip from
http://download.qt.io/archive/qt/5.6/5.6.0/single/ and unzip it in any location, for example C:\qt-everywhere-opensource-src-5.6.0.

Now open a “VS2015 x64 native tools command prompt”, CD to the location of the qt-everywhere-opensource-src-5.6.0 directory then:

cd qtbase\src\plugins\sqldrivers\odbc
C:\Qt\Qt5.6.0\5.6\msvc2015_64\bin\qmake odbc.pro

At the end you’ll find the qsqlodbc.dll in C:\qt-everywhere-opensource-src-5.6.0\qtbase\plugins\sqldrivers alogside with qsqlodbcd.dll and qsqlodbcd.pdb.

Just copy these three files to the location where the Qt 5.6 installer for Windows should have put them
C:\Qt\Qt5.6.0\5.6\msvc2015_64\plugins\sqldrivers\ and you’ll be done !


About paolog

homo technologicus cynicus
This entry was posted in C++, Howtos, Rants. Bookmark the permalink.

One Response to Where is the SQL database plugin for ODBC (qsqlodbc.dll) in Qt 5.6 ?

  1. avatar Kyle says:

    Thansk for this, I’d been trying to figure out why Qt didn’t load the driver for a while now.

Leave a Reply

Your email address will not be published. Required fields are marked *