源代码(带下载链接):
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",和/或&#34 ; -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
答案 0 :(得分:0)
我按照这些说明在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中使用了这个过程。
答案 1 :(得分:0)
除了Snowman6286的答案外,还必须执行以下操作以使用默认Qt进行构建:
Qt通常使用/ MD标志设置,因此必须以相同的方式构建MariaDB,以使Qt链接它。令人反感的行位于。\ cmake \ os \ Windows.cmake中。注释掉显示为STRING(REPLACE "/MD" "/MT" "${flag}" "${${flag}}")
的行。另外,请勿通过注释掉根CMakeLists.txt中的ADD_SUBDIRECTORY(win/upgrade_wizard)
行来构建升级向导。