MinGW

Create MySQL driver for Qt5 on Windows

This tutorial explains how to create the MySQL driver for Qt5 on Windows using MinGW. If you are looking for the tutorial to do this with Qt4, click here.

Step 1

Download all the needed software.

  • Qt (libraries and source code)
    This are two separate files! E.g. qt-windows-opensource-5.0.1-mingw47_32-x86-offline.exe and qt-everywhere-opensource-src-5.0.1.zip
  • MySQL Community Server (E.g. mysql-5.5.30-win32.msi)
    I didn't use version 5.6 because the .msi only allowed me to install the 64-bit version of the Client C API Library, which apparently gives errors later in the tutorial. So make sure you get the 32-bit verison! If you really want version 5.6, an option might be to download the 32-bit version of the source files and use those. Note that I didn't test this option, so I can't help you with that.

Step 2

Install the downloaded software.

  • Install Qt, the components I installed are the default ones. (See image 1)
  • Install MySQL, you only need to install the Client C API Library the other components are optional for this tutorial. (See image 2)

Building Poppler on Windows using MinGW

The E-Sheet project needed to be able to create and view PDF's. After looking around, I noticed a lot of people proposed to use Poppler, but to use it I needed to build the libraries. Since there isn't much information out there, I could only base my tries on this tutorial.

Downloads

  • Poppler (I used poppler-0.18.4)
  • Qt4 or the sources if you want to compile Qt as well. I tried them both and both were successful, so it's up to you.
  • MinGW download the installer (e.g. mingw-get-inst-20111118.exe)
  • CMake
  • Freetype
  • Cairo
    While building I encountered the following error:
    C:/.../CairoOutputDev.h:38:22: fatal error: cairo-ft.h: No such file or directory
    To solve this I moved the files located in the /include/cairo folder to the /include folder.
    Then another error occurred:
    C:/.../include/cairo-ft.h:50:35: fatal error: fontconfig/fontconfig.h: No such file or directory
    To solve this you will need to download Fontconfig. Once the download is complete copy the /include/fontconfig folder from the fontconfig archive into the cairo /include folder. The other parts of the fontconfig archive are not needed.
  • Openjpeg
  • Zlib

Create MySQL driver for Qt on Windows

As you might have seen I'm working on the E-Sheet project of the Royal Belgian Ice Hockey Federation (RBIHF). This project is created with Qt on a Windows system and requires a connection to a MySQL database. Since Qt doesn't deliver the MySQL driver by default, I had to created it myself. You can recognize the problem from the following error: Driver not loaded.

I checked out several tutorials but they were either unsuccessful or extremely slow or even both. The main reason they were unsuccessful is that they aren't compatible with the new Qt versions (4.7.x and up). I listed a few of them below:

  • Qt Documentation
    This one should work, but will take a lot of time, since you have to compile Qt. Another problem was that while configuring Qt the following error occurred: Perl not found in environment - cannot run syncqt. A solution for this error can be found here.
  • Christopher.rasch-olsen.no
  • Berenger.eu

After searching a while I found this solution. It works and it's fast. This is what you should do: