简体   繁体   English

QT MYSQL 驱动器构建,未定义对 `mysql_get_client_version@0' 的引用

[英]QT MYSQL drive build, undefined reference to `mysql_get_client_version@0'

I am trying to build the QMYSQL drive, I followed Document ( https://doc.qt.io/qt-5/sql-driver.html#how-to-build-the-qmysql-plugin-on-windows )我正在尝试构建 QMYSQL 驱动器,我遵循了文档( https://doc.qt.io/qt-5/sql-driver.html#how-to-build-the-qmysql-plugin-on-windows

it recommond me runned the code :它建议我运行代码:

cd %QTDIR%\qtbase\src\plugins\sqldrivers
qmake -- MYSQL_INCDIR=C:/MySQL/include "MYSQL_LIBDIR=C:/MYSQL/MySQL Server <version>/lib/opt"
nmake sub-mysql

There is no "Libs & Include Files" Module in mysql "Custom Install", so I select the folder from the sql serves. mysql“自定义安装”中没有“Libs & Include Files”模块,所以我从sql服务中选择了文件夹。

I run the code on cmd:我在cmd上运行代码:

cd C:\Qt\5.12.6\Src\qtbase\src\plugins\sqldrivers
qmake --  "MYSQL_INCDIR=C:/MySql/MySQL Server 8.0/include" "MYSQL_LIBDIR=C:/MySql/MySQL Server 8.0/lib"

the result is :结果是:

info: creating stash file C:\Qt\5.12.6\Src\qtbase\src\plugins\sqldrivers\.qmake.stash

Running configuration tests...
Checking for DB2 (IBM)... no
Checking for InterBase... no
Checking for MySQL... no
Checking for OCI (Oracle)... no
Checking for ODBC... yes
Checking for PostgreSQL... no
Checking for SQLite (version 2)... no
Checking for TDS (Sybase)... no
Done running configuration tests.

Configure summary:

Qt Sql Drivers:
  DB2 (IBM) .............................. no
  InterBase .............................. no
  MySql .................................. no
  OCI (Oracle) ........................... no
  ODBC ................................... yes
  PostgreSQL ............................. no
  SQLite2 ................................ no
  SQLite ................................. yes
    Using system provided SQLite ......... no
  TDS (Sybase) ........................... no

Qt is now configured for building. Just run 'mingw32-make'.
Once everything is built, you must run 'mingw32-make install'.
Qt will be installed into 'C:\Qt\5.12.6\mingw73_32'.

Prior to reconfiguration, make sure you remove any leftovers from
the previous build.

it seems like does not detected mysql.好像没有检测到mysql。 what should I do to build the mysql drive.我应该怎么做才能构建 mysql 驱动器。

I checked the the config log for qmake:我检查了 qmake 的配置日志:

    Trying source 5 (type inline) of library mysql ...
+ 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/MySQL Server 8.0/lib/libmysql.lib\"" "QMAKE_INCDIR_MYSQL = \"C:/MySql/MySQL Server 8.0/include\"" C:/Qt/5.12.6/Src/qtbase/src/plugins/sqldrivers/config.tests/mysql
> Info: creating stash file C:\Qt\5.12.6\Src\qtbase\src\plugins\sqldrivers\config.tests\.qmake.stash
+ cd /d C:\Qt\5.12.6\Src\qtbase\src\plugins\sqldrivers\config.tests\mysql && set MAKEFLAGS=& mingw32-make
> 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 -I"C:\MySql\MySQL Server 8.0\include" -IC:\Qt\5.12.6\mingw73_32\mkspecs\win32-g++  -o main.o main.cpp
> 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\MySQL Server 8.0\lib\libmysql.lib"   
> 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'
> collect2.exe: error: ld returned 1 exit status
> mingw32-make: *** [Makefile:66: mysql.exe] Error 1

I think here is my problem,我想这是我的问题,

undefined reference to `mysql_get_client_version@0'对 `mysql_get_client_version@0' 的未定义引用

but I do not know how to solve it.I am sure there is a "mysql.h" file in "include" folder with a method但我不知道如何解决它。我确定“include”文件夹中有一个带有方法的“mysql.h”文件

unsigned long STDCALL mysql_get_client_version(void); unsigned long STDCALL mysql_get_client_version(void);

I solved it.我解决了。

I solved It the qmake is 86X, and server is 64X.我解决了 qmake 是 86X,服务器是 64X。 change a 64X qmake worked更改 64X qmake 工作

this doc is better then old one.这个文档比旧的要好。

https://doc-snapshots.qt.io/qt5-5.14/sql-driver.html#how-to-build-the-qmysql-plugin-on-windows https://doc-snapshots.qt.io/qt5-5.14/sql-driver.html#how-to-build-the-qmysql-plugin-on-windows

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM