Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

build Qt5.12.4 for Ubuntu 18.04 MYSQL driver



  • Hi
    Could someone kindly tell me the proper method to build Qt5.12 with the mysql driver?
    I attempted:
    #/opt/Qt/5.12.4/Src# ./configure -sql-mysql
    producing the result:
    ERROR: The OpenGL functionality tests failed!
    You might need to modify the include and library search paths by editing QMAKE_INCDIR_OPENGL[_ES2],
    QMAKE_LIBDIR_OPENGL[_ES2] and QMAKE_LIBS_OPENGL[_ES2] in the mkspec for your platform.

    ERROR: Feature 'sql-mysql' was enabled, but the pre-condition 'libs.mysql' failed.

    Check config.log for details.


    my config.log file showed for mysql:
    /opt/Qt/5.12.4/Src# cat config.log | grep mysql
    Command line: -sql-mysql
    loaded result for library config.qtbase_sqldrivers.libraries.mysql
    Trying source 0 (type mysqlConfig) of library mysql ...
    mysql_config not found.
    Trying source 1 (type mysqlConfig) of library mysql ...
    mysql_config not found.
    Trying source 2 (type mysqlConfig) of library mysql ...
    mysql_config not found.
    Trying source 3 (type mysqlConfig) of library mysql ...
    mysql_config not found.
    Trying source 4 (type inline) of library mysql ...
    None of [libmysqlclient_r.so libmysqlclient_r.a] found in [] and global paths.
    Trying source 5 (type inline) of library mysql ...
    Trying source 6 (type inline) of library mysql ...
    None of [libmysqlclient.so libmysqlclient.a] found in [] and global paths.
    test config.qtbase_sqldrivers.libraries.mysql FAILED


    Apparently, the Qt configuration file is not able to find the libmysqlclient.so library files.
    However these exist on my Ubuntu 18.04 system as:
    /usr/lib/x86_64-linux-gnu$ ls | grep libmysqlclient
    libmysqlclient.a
    libmysqlclient_r.so
    libmysqlclient.so
    libmysqlclient.so.20
    libmysqlclient.so.20.3.19


    but apparently the Qt config file:
    /opt/Qt/5.12.4/Src/configuration file is not able to find the above files.
    Could someone kindly tell me how to proceed?
    Thanks,
    Phil


  • Lifetime Qt Champion

    Hi,

    It's explained in the documentation.



  • Hi SGaist,
    I had been scouring this documentation, and it's the first place I went to but it's still not clear to me and here's what happened when I do:
    root@bellatrix:/opt/Qt/5.12.4/Src/qtbase/src/plugins/sqldrivers# /opt/Qt/5.12.4/gcc_64/bin/qmake -- MYSQL_PREFIX=/usr/include/mysql
    Project ERROR: You cannot configure sqldrivers separately within a top-level build.

    root@bellatrix:/opt/Qt/5.12.4/Src/qtbase/src/plugins/sqldrivers# /opt/Qt/5.12.4/gcc_64/bin/qmake -- MYSQL_INCDIR=/usr/include/mysql -- MYSQL_LIBDIR=/usr/lib/x86_64-linux-gnu
    Project ERROR: You cannot configure sqldrivers separately within a top-level build.

    Thanks,
    Phil



  • Your Src dir is configured to build the whole Qt, so you cannot configure plugin folder separately.
    (Here's a good habit called shadow-building: Don't run configure / qmake in the source folder but in an empty build folder. This will keep the source clean.)
    If all you want is just the mysql plugin, you don't need to build Qt.
    Get a clean source, and follow the instruction from the documentation again.



  • @montanaviking said in build Qt5.12.4 for Ubuntu 18.04 MYSQL driver:

    Project ERROR: You cannot configure sqldrivers separately within a top-level build.

    Hi SGaist, Bonnie,
    I did the following:
    cd $QTDIR/qtbase/src/plugins/sqldrivers

    touch .qmake.stash

    touch .qmake.super

    qmake -- MYSQL_PREFIX=/usr/local

    make sub-mysql

    make

    make install

    It appears that adding empty .qmake.stash and .qmake.super to the $QTDIR/qtbase/src/plugins/sqldrivers directory
    was necessary to enable the build of the mysql driver.
    It appears I can now open the mysql database from my Qt5.12.4 program without error.
    Thanks and best,
    Phil



  • Hi, I am running Qt5.12.4 with Ubuntu 18.04 64-bit and the following is how I compiled Qt statically:
    Install Qt+source to directorysource this is the downloaded and installed source Qt5.12.4 code
    mkdir directorystaticcompile this is the directory where configure, make, and make install are run
    mkdir directorystaticinstall this is where the compiled Qt5.12.4 libraries and includes, etc.. are installed

    $ cd directorystaticcompile
    $ sudo directorysource/configure -v -static -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype -qt-xcb -make libs -nomake tools -nomake examples -nomake tests -opensource -confirm-license -egl -opengl es2 -skip wayland -prefix directorystaticinstall -sql-mysql -feature-freetype -fontconfig

    The above will build Qt and takes a few hours on most computers

    After the build is complete:

    $ sudo make

    The above will take a few minutes

    Then:

    $ sudo make install

    The above finishes the install
    Best,
    Phil


Log in to reply