Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Library 'mysql' is not defined
Forum Updated to NodeBB v4.3 + New Features

Library 'mysql' is not defined

Scheduled Pinned Locked Moved Solved General and Desktop
22 Posts 6 Posters 8.2k Views 5 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Christian EhrlicherC Christian Ehrlicher

    Since qmake did not output anything according to your logs you should remove config.cache and start over (already told you above somewhere)

    H Offline
    H Offline
    hobbyProgrammer
    wrote on last edited by hobbyProgrammer
    #21

    @Christian-Ehrlicher alright, I managed to get these files in C:/Qt/Qt5.13.1/5.13.1/Src/qtbase/src/plugins/sqldrivers/plugins/sqldrivers:

    • qsqlmysql.dll
    • qsqlmysqld.dll
    • qsqlmysql.a
    • qsqlmysqld.a

    but for some reason I still get this error:

    build-testDatabaseDrivers-Desktop_Qt_5_13_1_MinGW_64_bit-Debug\debug\testDatabaseDrivers.exe ...
    ("QSQLITE", "QODBC", "QODBC3", "QPSQL", "QPSQL7")
    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7
    

    EDIT:

    I copied the .dll files to C:/Qt/Qt<version>/<version>/mingw73_32/plugins/sqldrivers
    and now it works

    1 Reply Last reply
    0
    • H Offline
      H Offline
      hobbyProgrammer
      wrote on last edited by
      #22

      This worked for me and I used:

      • OS: Windows
      • Qt version: 5.13.1 and 5.13.2
      • Qt creator: 4.10.1
      • compiler: mingw73_32

      Step by step:

      1. Download msys & msysgit
      2. Open the cmd of msys and type these commands (keep in mind that the second and third command do not contain cd. You need to call the .exe files from the mysql path):
      • cd <path to libmysql.lib>
      • C:/msysgit/mingw/bin/reimp.exe libmysql.lib
      • C:/msysgit/mingw/bin/dlltool.exe -k -d libmysql.def -l libmysql.a
      1. go to the qt cmd called: Qt <version> (<compiler>). Use the one with the mingw32 compiler.
      2. execute the following commands:
      • cd C:/Qt/Qt<version>/<version>/Src/qtbase/src/plugins/sqldrivers
      • qmake sqldrivers.pro
      1. open mysql.pro and make sure that it looks like this (change the include path and the lib path, but make sure that the include path and the depend path are the same!) and save after you finished editing it:
      TARGET = qsqlmysql
      
      HEADERS += $$PWD/qsql_mysql_p.h
      SOURCES += $$PWD/qsql_mysql.cpp $$PWD/main.cpp
      
      #QMAKE_USE += mysql
      LIBS += -L'C:/MySQL/lib/'
      -llibmysql
      
      INCLUDEPATH += 'C:/MySQL/include'
      
      DEPENDPATH += 'C:/MySQL/include'
      
      
      OTHER_FILES += mysql.json
      
      PLUGIN_CLASS_NAME = QMYSQLDriverPlugin
      include(../qsqldriverbase.pri)
      
      
      1. execute the following commands:
      • qmake mysql.pro
      • qmake "INCLUDEPATH+=<includepath>" "LIBS+=<libpath>/libmysql.lib" mysql.pro
      • mingw32-make
      1. go to C:/Qt/Qt<version>/<version>/Src/qtbase/src/plugins/sqldrivers/plugins/sqldrivers in the file explorer. You should see these four files now:
      • qsqlmysql.dll
      • qsqlmysqld.dll
      • qsqlmysql.a
      • qsqlmysqld.a
      1. copy them and place them into: C:/Qt/Qt<version>/<version>/mingw73_32/plugins/sqldrivers
      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved