简体   繁体   中英

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)?

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:

    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 :

    Project ERRROR: No module claims plugin type 'sqldrivers'

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

Following link (Qt Documentation) is code format because "You need at least 10 reputation to post more than 2 links."

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

---- 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. 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:
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:

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.

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.

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. I used this process with QT 5.7.1.

In addition to the answer from Snowman6286, the following must be done for building with default Qt:

Qt is built with the /MD flag set normally, so MariaDB must be built in the same way for Qt to link it. The offending line is in .\\cmake\\os\\Windows.cmake. Comment out the line that reads 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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