Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Why is my qt5.5 not linking to mysql?


Asked by Marisol Hutchinson on Dec 10, 2021 MySQL



In Short:I am trying to link my Qt5.5 to MySQL but it is not working. The long storybegins when I tried to use MySQLas in: QSqlDatabase theDatabase = QSqlDatabase::addDatabase("QMYSQL"); But when I run my application, I get the following messages: QSqlDatabase: QMYSQL driver not loaded
Subsequently,
To see if it has detected MySQL, after it's done checking, search for "Qt Sql Drivers:" under "Build options" section: If MySQL says yes (like in the picture above), congrats, it detected your MySQL. If it gives you error: ERROR: Feature 'sql-mysql' was enabled, but the pre-condition 'libs.mysql' failed., it probably couldn't detect MySQL.
Thereof, To use the embedded MySQL server, simply link the Qt plugin to libmysqld instead of libmysqlclient. This can be done by adding MYSQL_LIBS=-lmysqld to the configure command line. Please refer to the MySQL documentation, chapter "libmysqld, the Embedded MySQL Server Library" for more information about the MySQL embedded server.
Similarly,
The widget I used inherited from QOpenGLWidget, but the openGL function calls (like glClearColor) tried to access native openGL implementation in Qt. which Since those were not included in my Qt build, the project would not build. To fix this one has to either run a custom Qt core build, or use the openGL wrapper provided by Qt.
Consequently,
Qt Documentation. The Qt SQL module uses driver plugins to communicate with the different database APIs. Since Qt's SQL Module API is database-independent, all database-specific code is contained within these drivers. Several drivers are supplied with Qt, and other drivers can be added.