繁体   English   中英

使用 MariaDB 在 Windows 上构建 MYSQL/QMYSQL 插件时出错

[英]Error Building MYSQL / QMYSQL Plugin on Windows with MariaDB

  • 如何让这个配置/构建过程工作?
  • 为什么会出现下面提到的不同 QMAKE ERRORS(如果可能,请详细说明)?

源代码(带下载链接):

MariaDB 5.5.56
https://downloads.mariadb.org/mariadb/5.5.56/
Qt 5.7.1
https://download.qt.io/official_releases/qt/5.7/5.7.1/single/

我在以下目录中解压并成功构建了 MariaDB 5.5.56:

    D:\Source_Code-Third_Party\MariaDB\mariadb-5.5.56
Note: I "mkdir lib" and copy all ".lib"s into this folder post-build process.

然后我通过我编写的批处理脚本使用以下命令:

    set QMAKESPEC=win32-msvc2015
    set _ROOT=

    set VS2015PATH="C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC"
    pushd %VS2015PATH%
    call vcvarsall.bat x64
    popd

    set CL=/MP
    set INSTPREFIX=D:\Qt\5.7.1
    set OPENSSL_PATH=%usefulStuff%
    set OPENSSL_LIBS=%usefulStuff%\libs
    set INCLUDE=%usefulStuff%\include;%INCLUDE%
    set LIB=%usefulStuff%\lib;%LIB%
    set LIBPATH=%usefulStuff%\lib;%LIBPATH%

    cd qtbase

    configure.bat -skip qtwebengine -skip qtpurchasing -skip qtlocation -skip qtconnectivity -mp -confirm-licence -nomake tests -nomake examples -debug-and-release -opensource -shared -dbus -mp -openssl -qtzlib -plugin-sql-mysql -I %usefulStuff%\include -L %usefulStuff%\lib -prefix %INSTPREFIX%

    cd src\plugins\sqldrivers\mysql
    set longDir=D:\Source_Code-Third_Party\qt-everywhere-opensource-src-5.7.1

    REM           (QMAKE COMMAND THAT CAUSES ERROR)
    %longDir%\qtbase\bin\qmake "INCLUDEPATH+= D:/Source_Code-Third_Party/MariaDB/mariadb-5.5.56/include" "LIBS+=D:/Source_Code-Third_Party/MariaDB/mariadb-5.5.56/lib/libmysql.lib" mysql.pro

    REM unsure if I should do an nmake here as well, or will the qtbase\nmake take care of everything (including plugin)
    REM nmake

    cd ..\..\..\..

    nmake
    nmake install

使用上述(QMAKE ERROR COMMAND),我得到错误

    Project ERRROR: No module claims plugin type 'sqldrivers'

当我将 (QMAKE ERROR COMMAND) 更改为以下内容时(使用不同的 qmake):

    %longDir%\qtbase\qmake\qmake "INCLUDEPATH+= D:/Source_Code-Third_Party/MariaDB/mariadb-5.5.56/include" "LIBS+=D:/Source_Code-Third_Party/MariaDB/mariadb-5.5.56/lib/libmysql.lib" mysql.pro

我得到一个不同的错误

     Project ERROR: Cannot load qmodule.pri!
     Error processing project file: mysql.pro

我能找到的一些参考资料:
https://forum.qt.io/topic/51808/notorious-qsqldatabase-qmysql-driver-not-loaded-but-available/4

以下链接(Qt 文档)是代码格式,因为“您需要至少 10 个声望才能发布 2 个以上的链接。”

    http://doc.qt.io/qt-5/sql-driver.html#qmysql-for-mysql-4-and-higher

本来可以用“qmysql”标记这个问题,但是“创建新标签‘qmysql’至少需要 1500 个声望。请尝试从现有标签列表中尝试一些东西。”

---- 下面是相关的,但我更关心上面提到的错误----
我没有使用 Qt 5.8.0 或 5.9.0,因为我无法使用“-skip”、“-plugin-sql-mysql”和/或“-qt-sql-mysql”来使用 configure.bat。 我收到如下错误:

    "-qt-sql-mysql"
    ERROR: Invalid value given for boolean command line option 'sql-mysql'.
                               OR
    "-plugin-sql-mysql"
    ERROR: Feature 'sql-mysql' was enabled, but the pre-condition 'libs.mysql' failed.
    Check config.log for details.
                               OR
    "-skip <somethingIShouldBeAbleToSkip>"
    ERROR: Unknown command line option '-skip'.

我发现的 QTBUG 参考资料之一:
https://bugreports.qt.io/browse/QTBUG-58536

  • 如果有人/人要回答两个问题以及更多问题,那就太棒了!
  • 谢谢大家!!

我按照以下说明在 Windows 上构建 MariaDB:

https://mariadb.com/kb/en/the-mariadb-library/Building_MariaDB_on_Windows/

构建后,您还应该继续安装到您的系统上。 此安装过程将所有内容放入 QT 构建过程的正确文件夹结构中。

一旦你安装了 MariaDB(它应该看起来就像一个 MySQL 安装),你应该能够遵循 MySQL 的标准 QT 构建说明。

http://doc.qt.io/qt-5/sql-driver.html

在配置 QT 时使用类似于“-qt-sql-mysql -IC:\\progra~1\\mysql\\include -LC:\\progra~1\\mysql\\lib”的东西。 我在 QT 5.7.1 中使用了这个过程。

除了来自 Snowman6286 的回答之外,使用默认 Qt 构建还必须执行以下操作:

Qt 构建时通常设置了 /MD 标志,因此必须以相同的方式构建 MariaDB,Qt 才能链接它。 有问题的行在 .\\cmake\\os\\Windows.cmake 中。 注释掉读取STRING(REPLACE "/MD" "/MT" "${flag}" "${${flag}}") 此外,不要通过注释掉根 CMakeLists.txt 中读取ADD_SUBDIRECTORY(win/upgrade_wizard)的行来构建升级向导。

暂无
暂无

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

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