Results 1 to 2 of 2

Thread: QT MYSQL drive build, undefined reference to `mysql_get_client_version@0'

  1. #1
    Join Date
    Dec 2019
    Posts
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QT MYSQL drive build, undefined reference to `mysql_get_client_version@0'

    Hi, I am struggling these for three days. I tried all I can do, and I believes this can be the last problem for me.

    I am trying to build the QMYSQL drive, I followed Document (https://doc.qt.io/qt-5/sql-driver.ht...gin-on-windows)

    There is no "Libs & Include Files" Module in mysql "Custom Install", so I select the folder from the sql serves.

    I run the code on cmd:

    Qt Code:
    1. cd C:\Qt\5.12.6\Src\qtbase\src\plugins\sqldrivers
    2. qmake -- "MYSQL_INCDIR=C:/MySql/MySQL Server 8.0/include" "MYSQL_LIBDIR=C:/MySql/MySQL Server 8.0/lib"
    To copy to clipboard, switch view to plain text mode 

    the result is :

    Qt Code:
    1. Info: creating stash file C:\Qt\5.12.6\Src\qtbase\src\plugins\sqldrivers\.qmake.stash
    2.  
    3. Running configuration tests...
    4. Checking for DB2 (IBM)... no
    5. Checking for InterBase... no
    6. Checking for MySQL... no
    7. Checking for OCI (Oracle)... no
    8. Checking for ODBC... yes
    9. Checking for PostgreSQL... no
    10. Checking for SQLite (version 2)... no
    11. Checking for TDS (Sybase)... no
    12. Done running configuration tests.
    13.  
    14. Configure summary:
    15.  
    16. Qt Sql Drivers:
    17. DB2 (IBM) .............................. no
    18. InterBase .............................. no
    19. MySql .................................. no
    20. OCI (Oracle) ........................... no
    21. ODBC ................................... yes
    22. PostgreSQL ............................. no
    23. SQLite2 ................................ no
    24. SQLite ................................. yes
    25. Using system provided SQLite ......... no
    26. TDS (Sybase) ........................... no
    27.  
    28. Qt is now configured for building. Just run 'mingw32-make'.
    29. Once everything is built, you must run 'mingw32-make install'.
    30. Qt will be installed into 'C:\Qt\5.12.6\mingw73_32'.
    31. Prior to reconfiguration, make sure you remove any leftovers from
    32. the previous build.
    To copy to clipboard, switch view to plain text mode 

    it seems like does not detected mysql.

    I check the the mysql log,
    Qt Code:
    1. Command line: "MYSQL_INCDIR=C:/MySql/MySQL Server 8.0/include" "MYSQL_LIBDIR=C:/MySql/MySQL Server 8.0/lib"
    2. Global lib dirs: [C:\\openssl\\lib C:\\Utils\\my_sql\\mysql-5.6.11-win32\\lib C:\\Utils\\postgresql\\pgsql\\lib] [C:/Qt/Tools/mingw730_32/lib/gcc/i686-w64-mingw32/7.3.0 C:/Qt/Tools/mingw730_32/lib/gcc C:/Qt/Tools/mingw730_32/i686-w64-mingw32/lib C:/Qt/Tools/mingw730_32/lib]
    3. Global inc dirs: [C:\\openssl\\include C:\\Utils\\my_sql\\mysql-5.6.11-win32\\include C:\\Utils\\postgresql\\pgsql\\include] [C:/Qt/Tools/mingw730_32/lib/gcc/i686-w64-mingw32/7.3.0/include/c++ C:/Qt/Tools/mingw730_32/lib/gcc/i686-w64-mingw32/7.3.0/include/c++/i686-w64-mingw32 C:/Qt/Tools/mingw730_32/lib/gcc/i686-w64-mingw32/7.3.0/include/c++/backward C:/Qt/Tools/mingw730_32/lib/gcc/i686-w64-mingw32/7.3.0/include C:/Qt/Tools/mingw730_32/lib/gcc/i686-w64-mingw32/7.3.0/include-fixed C:/Qt/Tools/mingw730_32/i686-w64-mingw32/include]
    4. .......
    5. looking for library mysql
    6. .....
    7. Trying source 5 (type inline) of library mysql ...
    8. + cd /d C:\Qt\5.12.6\Src\qtbase\src\plugins\sqldrivers\config.tests\mysql && C:\Qt\5.12.6\mingw73_32\bin\qmake.exe "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch" "QMAKE_LIBDIR += C:\\openssl\\lib C:\\Utils\\my_sql\\mysql-5.6.11-win32\\lib C:\\Utils\\postgresql\\pgsql\\lib" "INCLUDEPATH += C:\\openssl\\include C:\\Utils\\my_sql\\mysql-5.6.11-win32\\include C:\\Utils\\postgresql\\pgsql\\include" "QMAKE_USE += mysql" "QMAKE_LIBS_MYSQL = C:/MySQL/lib/libmysql.lib" "QMAKE_INCDIR_MYSQL = C:/MySQL/include" C:/Qt/5.12.6/Src/qtbase/src/plugins/sqldrivers/config.tests/mysql
    9. > Info: creating stash file C:\Qt\5.12.6\Src\qtbase\src\plugins\sqldrivers\config.tests\.qmake.stash
    10. + cd /d C:\Qt\5.12.6\Src\qtbase\src\plugins\sqldrivers\config.tests\mysql && set MAKEFLAGS=& mingw32-make
    11. > g++ -c -fno-keep-inline-dllexport -O2 -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -I. -IC:\openssl\include -IC:\Utils\my_sql\mysql-5.6.11-win32\include -IC:\Utils\postgresql\pgsql\include -IC:\MySQL\include -IC:\Qt\5.12.6\mingw73_32\mkspecs\win32-g++ -o main.o main.cpp
    12. > g++ -Wl,-s -Wl,-subsystem,console -mthreads -o mysql.exe main.o -LC:\openssl\lib -LC:\Utils\my_sql\mysql-5.6.11-win32\lib -LC:\Utils\postgresql\pgsql\lib C:\MySQL\lib\libmysql.lib
    13. > c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: main.o:main.cpp:(.text.startup+0xc): undefined reference to `mysql_get_client_version@0'
    14. > collect2.exe: error: ld returned 1 exit status
    15. > mingw32-make: *** [Makefile:66: mysql.exe] Error 1
    To copy to clipboard, switch view to plain text mode 

    the problems seems like because of undefined reference to `mysql_get_client_version@0'

    I checked the mysql/include. I am sure there is a "mysql.h" file, and a mysql_get_client_version function exisit, but it just a headfile, not even defined.

    What should I do to build a MYSQL drive? thank you very much.

    I also tried the method from the video https://www.youtube.com/watch?v=r1TbNjJSlX8&t=199s
    it reported the error, library mysql is not definied.


    Added after 26 minutes:


    I solved It. The lib and include file should be comes from the MySQL Connector C 6.1.

    this doc is better then old one.

    https://doc-snapshots.qt.io/qt5-5.14...gin-on-windows
    Last edited by hehedaouziteng; 31st December 2019 at 19:45.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,625
    Thanks
    13
    Thanked 1,592 Times in 1,520 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QT MYSQL drive build, undefined reference to `mysql_get_client_version@0'

    The placement of double-quotes in the qmake command line from the original docs was likely to cause you problems even if you had the correct libraries in place.

Similar Threads

  1. Problem with MySQL drive on mac
    By Eduardo Huerta in forum Newbie
    Replies: 1
    Last Post: 1st April 2019, 05:52
  2. Replies: 0
    Last Post: 11th March 2013, 05:40
  3. Replies: 0
    Last Post: 15th July 2011, 03:21
  4. Undefined reference to crt
    By derektaprell in forum Installation and Deployment
    Replies: 0
    Last Post: 20th October 2009, 08:34
  5. Undefined Reference To...
    By ManuMies in forum Qt Programming
    Replies: 6
    Last Post: 10th February 2009, 12:14

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.