【问题标题】:Error Building MYSQL / QMYSQL Plugin on Windows with MariaDB使用 MariaDB 在 Windows 上构建 MYSQL/QMYSQL 插件时出错
【发布时间】:2020-01-11 07:11:57
【问题描述】:
  • 如何让这个配置/构建过程正常工作?
  • 为什么会出现下面提到的不同 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),我得到 ERROR

    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

  • 如果有人/人们要回答这两个问题等等,那就太棒了!
  • 提前谢谢大家!!

【问题讨论】:

    标签: c++ mysql qt5 mariadb qmake


    【解决方案1】:

    我按照这些说明在 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 -I C:\progra~1\mysql\include -L C:\progra~1\mysql\lib”的东西。我在 QT 5.7.1 中使用了这个过程。

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

        猜你喜欢
        • 2019-07-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-02-12
        • 1970-01-01
        • 2019-10-11
        • 2013-08-12
        • 2021-09-15
        相关资源
        最近更新 更多