Running Qt + MySQL application
Yesterday I tried to run my university project made with Qt and MySQL. But all I got was strange error message, saying QMYSQL driver is not loaded whilst loaded driver list actually included that one.
Searching all over the internet up ‘til 2 AM and recompiling the whole Qt gave no result except time being wasted. Yeah, and 90% of search results were tutorials on how to recompile Qt MySQL plugin under Windows.
Yet in the morning I found solution and it was beautifully simple! I just performed one step from Deploying Qt applications, actually just copied the plugins/ directory to the dir where the application executable lives (build-debug/ or build-release/ for my project; I hate the default build-#{ProjectName}-Desktop_5_4_1-Debug/ paths); included the sqldrivers/ directory there (just copied) and created (a bit tuned although) the qt.conf file. That file just pointed the plugins path to the custom one:
[Paths]
Prefix=.
Plugins=./plugins
To sum everything up:
- create a
plugins/directory in your build directory - copy
Qt/5.4/Src/qtbase/plugins/platforms/there - copy
Qt/5.4/gcc_64/plugins/sqldrivers/there too - create
qt.conffile in build directory and fill it as mentioned above
And one more hint before the end: to debug why your Qt plugins fail use this application startup switch: QT_DEBUG_PLUGINS=1 ./app_name - this will display plugins debug information.