After build and install MySql driver for Qt it's unable to load the MySql Drive

为君一笑 提交于 2020-06-16 17:33:31

问题


I'm already build and install the MySql drive like here.. But still I got the error message QMYSQL driver not loaded. Now it;s say MySql as a available driver. I'm using 64bit windows, Qt creator version 32-bit, mingw81_64 and MySql 64 bit Error is,

" QMYSQL driver not loaded. available drivers: QSQLITE QMARIADB QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7"


回答1:


Probably you don't have the libmysql.dll (or libmariadb.dll) in your path. The mechanism is that the MySQL database plugin dll is dymanically loaded runtime, and even if the database plugin itself is present (therefore listed as available), it might fail to load if the libmysql.dll (or libmariadb.dll) is not found.




回答2:


This question is already answered here. Enough details are provided there. In brief:

  1. Download proper libmysql.lib based on your Qt creator version (32-bit?)
  2. Put that dll in your build directory (to see your project's build directory, click the "Projects" button on the left menu bar on Qt creator and see the "Build directory")
  3. Build and run

Edit 1:

One more thing: when you download different versions of libmysql.dll, do as follows:

  • Right click on your application project and select "Add Library"
  • A dialog opens. Select "External library" radio button and click "Next"
  • For the "Library file", brows for your libmysql.lib and select it
  • In the "Platform" section, select the proper platform (windows, linux, ...)
  • If you are a windows user, make sure to check the "Library inside "debug" or "release" subfolder" checkbox
  • Click next

This is the most reliable way to add a library to your project. Hope this helps.



来源:https://stackoverflow.com/questions/62028982/after-build-and-install-mysql-driver-for-qt-its-unable-to-load-the-mysql-drive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!