简体   繁体   English

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

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

  • How to get this configure/build process working?如何让这个配置/构建过程工作?
  • Why the different QMAKE ERRORS mentioned below occur (in detail if possible)?为什么会出现下面提到的不同 QMAKE ERRORS(如果可能,请详细说明)?

Source code (w/ Download links):源代码(带下载链接):

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/

I unzip & successfully build MariaDB 5.5.56 in the following directory:我在以下目录中解压并成功构建了 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.

I then use the following commands via batch script(s) that I wrote:然后我通过我编写的批处理脚本使用以下命令:

    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

With the above (QMAKE ERROR COMMAND), I get the ERROR :使用上述(QMAKE ERROR COMMAND),我得到错误

    Project ERRROR: No module claims plugin type 'sqldrivers'

When I change the (QMAKE ERROR COMMAND) to the following (using different qmake):当我将 (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

I get a different ERROR :我得到一个不同的错误

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

Some references that I was able to find:我能找到的一些参考资料:
https://forum.qt.io/topic/51808/notorious-qsqldatabase-qmysql-driver-not-loaded-but-available/4 https://forum.qt.io/topic/51808/notorious-qsqldatabase-qmysql-driver-not-loaded-but-available/4

Following link (Qt Documentation) is code format because "You need at least 10 reputation to post more than 2 links."以下链接(Qt 文档)是代码格式,因为“您需要至少 10 个声望才能发布 2 个以上的链接。”

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

Would have tagged this question with "qmysql", but "Creating the new tag 'qmysql' requires at least 1500 reputation. Try something from the existing tags list instead."本来可以用“qmysql”标记这个问题,但是“创建新标签‘qmysql’至少需要 1500 个声望。请尝试从现有标签列表中尝试一些东西。”

---- Below is related, but I care more about the errors mentioned above ---- ---- 下面是相关的,但我更关心上面提到的错误----
I am not using Qt 5.8.0 or 5.9.0 because I can't get "-skip", "-plugin-sql-mysql", and/or "-qt-sql-mysql" to work with configure.bat.我没有使用 Qt 5.8.0 或 5.9.0,因为我无法使用“-skip”、“-plugin-sql-mysql”和/或“-qt-sql-mysql”来使用 configure.bat。 I get ERRORS like:我收到如下错误:

    "-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'.

One of the QTBUG references I found:我发现的 QTBUG 参考资料之一:
https://bugreports.qt.io/browse/QTBUG-58536 https://bugreports.qt.io/browse/QTBUG-58536

  • If someone/people were to answer both questions & more, that would just be awesome!如果有人/人要回答两个问题以及更多问题,那就太棒了!
  • Thank you all in advance!!谢谢大家!!

I followed these instructions for building MariaDB on Windows:我按照以下说明在 Windows 上构建 MariaDB:

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

After you build, you should also go ahead and Install onto your system.构建后,您还应该继续安装到您的系统上。 This install process puts everything in the correct folder structure for the QT build process.此安装过程将所有内容放入 QT 构建过程的正确文件夹结构中。

Once you have installed MariaDB (it should look just like a MySQL install), you should be able to follow the standard QT build directions for MySQL.一旦你安装了 MariaDB(它应该看起来就像一个 MySQL 安装),你应该能够遵循 MySQL 的标准 QT 构建说明。

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

Using something similar to "-qt-sql-mysql -IC:\\progra~1\\mysql\\include -LC:\\progra~1\\mysql\\lib" when configuring QT.在配置 QT 时使用类似于“-qt-sql-mysql -IC:\\progra~1\\mysql\\include -LC:\\progra~1\\mysql\\lib”的东西。 I used this process with QT 5.7.1.我在 QT 5.7.1 中使用了这个过程。

In addition to the answer from Snowman6286, the following must be done for building with default Qt:除了来自 Snowman6286 的回答之外,使用默认 Qt 构建还必须执行以下操作:

Qt is built with the /MD flag set normally, so MariaDB must be built in the same way for Qt to link it. Qt 构建时通常设置了 /MD 标志,因此必须以相同的方式构建 MariaDB,Qt 才能链接它。 The offending line is in .\\cmake\\os\\Windows.cmake.有问题的行在 .\\cmake\\os\\Windows.cmake 中。 Comment out the line that reads STRING(REPLACE "/MD" "/MT" "${flag}" "${${flag}}") .注释掉读取STRING(REPLACE "/MD" "/MT" "${flag}" "${${flag}}") In addition, don't let the upgrade wizard build by commenting out the line that reads ADD_SUBDIRECTORY(win/upgrade_wizard) in the root CMakeLists.txt.此外,不要通过注释掉根 CMakeLists.txt 中读取ADD_SUBDIRECTORY(win/upgrade_wizard)的行来构建升级向导。

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

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