Problems with Open-Source Downloads read and

Ubuntu QMYSQL driver loaded error.

  • I already tried to fix it but nothing works... Here is a list of what i already did (I am a total beginner in linux so i might have failed to execute the solutions...)

    I did compile the source with sudo ./configure -sql-mysql followed by sudo make and sudo make install in the /opt/Qt/5.9.1/src/ and the result of this is /usr/Qt-5.9.1/ being created and has files in it including plugins/sqldrivers/
    I installed (they were already) mysql-server, mysql-server-5.7, mysql-client, mysql-client-5.7. The MySQL version running for my apache server is 5.7
    I added variables in the .pro file QT += sql, QTPLUGIN += qsqlmysql, CONFIG += c++11, INCLUDEPATH += /usr/include/mysql\ /usr/local/Qt-5.9.1/plugins/sqldrivers \ /usr/local/Qt-5.9.1 \ /usr/local/Qt-5.9.1/lib, LIBS+=-L/usr/lib -lmysqlclient_r, INCLUDEPATH+=/usr/local/Qt-5.9.1/plugins/sqldrivers/ but when i do cd /usr/bin followed by -lmysqlclient_r i get a command not found error.
    I also did something related with ln command but i cannot find the links i found the answers on so im not sure about what it did exactly

    I do not know if it has importance but my ide is set with Qt 5.9.1 and uses qmake for version 5.9.1 but i did download some qt 4 stuff with apt so when i do qmake -v i have version 5.5.1 in my command line.

    I thought about downloading the 30days trial commercial version to get the driver already compiled but im not sure if when the trial will expire i will still be able to use the QMYSQL driver.

    /usr/lib$ ls | grep sql

    The following are list of packages i installed

    sudo dpkg --get-selections | grep qt
    appmenu-qt:amd64                install
    appmenu-qt5                 install
    libaccounts-qt5-1:amd64             install
    libdbusmenu-qt2:amd64               install
    libdbusmenu-qt5:amd64               install
    libgsettings-qt1:amd64              install
    liboxideqt-qmlplugin:amd64          install
    liboxideqtcore0:amd64               install
    liboxideqtquick0:amd64              install
    libqt4-dbus:amd64               install
    libqt4-declarative:amd64            install
    libqt4-designer:amd64               install
    libqt4-dev                  install
    libqt4-dev-bin                  install
    libqt4-help:amd64               install
    libqt4-network:amd64                install
    libqt4-opengl:amd64             install
    libqt4-opengl-dev               install
    libqt4-qt3support:amd64             install
    libqt4-script:amd64             install
    libqt4-scripttools:amd64            install
    libqt4-sql:amd64                install
    libqt4-sql-mysql:amd64              install
    libqt4-sql-sqlite:amd64             install
    libqt4-svg:amd64                install
    libqt4-test:amd64               install
    libqt4-xml:amd64                install
    libqt4-xmlpatterns:amd64            install
    libqt5concurrent5:amd64             install
    libqt5core5a:amd64              install
    libqt5dbus5:amd64               install
    libqt5feedback5:amd64               install
    libqt5gui5:amd64                install
    libqt5multimedia5:amd64             install
    libqt5network5:amd64                install
    libqt5opengl5:amd64             install
    libqt5opengl5-dev:amd64             install
    libqt5organizer5:amd64              install
    libqt5positioning5:amd64            install
    libqt5printsupport5:amd64           install
    libqt5qml5:amd64                install
    libqt5quick5:amd64              install
    libqt5quicktest5:amd64              install
    libqt5sql5:amd64                install
    libqt5sql5-mysql:amd64              install
    libqt5sql5-sqlite:amd64             install
    libqt5svg5:amd64                install
    libqt5test5:amd64               install
    libqt5webkit5:amd64             install
    libqt5widgets5:amd64                install
    libqt5xml5:amd64                install
    libqtcore4:amd64                install
    libqtdbus4:amd64                install
    libqtgui4:amd64                 install
    libsignon-qt5-1:amd64               install
    libunity-action-qt1:amd64           install
    oxideqt-codecs:amd64                install
    qml-module-qt-labs-folderlistmodel:amd64    install
    qml-module-qt-labs-settings:amd64       install
    qml-module-qtfeedback:amd64         install
    qml-module-qtgraphicaleffects:amd64     install
    qml-module-qtquick-layouts:amd64        install
    qml-module-qtquick-window2:amd64        install
    qml-module-qtquick2:amd64           install
    qml-module-qttest:amd64             install
    qt-at-spi:amd64                 install
    qt4-linguist-tools              install
    qt4-qmake                   install
    qt5-default:amd64               install
    qt5-qmake:amd64                 install
    qt5-qmake-arm-linux-gnueabihf:amd64     install
    qtbase5-dev:amd64               install
    qtbase5-dev-tools               install
    qtchooser                   install
    qtcore4-l10n                    install
    qtdeclarative5-accounts-plugin:amd64        install
    qtdeclarative5-dev-tools            install
    qtdeclarative5-qtquick2-plugin:amd64        install
    qtdeclarative5-test-plugin:amd64        install
    qtdeclarative5-ubuntu-ui-toolkit-plugin     install
    qtdeclarative5-unity-action-plugin:amd64    install
    qttranslations5-l10n                install
    sni-qt:amd64                    install
    sudo dpkg --get-selections | grep mysql
    dbconfig-mysql                  install
    libmysql++3v5                   install
    libmysql-java                   install
    libmysqlclient-dev              install
    libmysqlclient16:amd64              install
    libmysqlclient20:amd64              install
    libqt4-sql-mysql:amd64              install
    libqt5sql5-mysql:amd64              install
    mysql-apt-config                install
    mysql-client                    install
    mysql-client-5.7                install
    mysql-client-core-5.7               install
    mysql-common                    install
    mysql-server                    install
    mysql-server-5.7                install
    mysql-server-core-5.7               install
    php-mysql                   install
    php7.0-mysql                    install

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Are you sure you are using your custom Qt build ?

    From the command line, that's normal, the qmake found is the one from your distribution. If you want to use yours just use the full path.

  • @SGaist Sorry but i am a little bit confused with custom Qt build, do you mean downloading the source package in the installer? (I'm currently reinstalling the whole Qt 5.9.1 package). I might miss something by the way

    cd /path/to/Qt
    ./configure -static -prefix /path/to/Qt <other parameters>

    I saw this on the Qt for Linux/X11 page. Does /path/to/Qt means the path the installer installed Qt or where ever i want

  • Lifetime Qt Champion

    It means the path to where your Qt sources are located, whether it is cloned from git or downloaded through the installer is irrelevant. Furthermore, you should rather use an out of source build which means call configure from another folder i.e:

    cd ~/
    mkdir build_qt5
    cd build_qt5
    /path/to/sources/of/Qt/configure -your-options

    Also note that static builds comes with additional license constraints.

  • @SGaist Ok i just did that

    /opt/Qt/5.9.1/Src/qtbase/configure -top-level -prefix /home/kosta/build_qt5/ -sql-mysql

    Now i will run make and make install in /home/kosta/build_qt5/ then what should i do?

  • Lifetime Qt Champion

    If you are using Qt Creator, go to Build and Run, add a new Qt version for it and create a new Kit for that Qt version.

  • @SGaist So i went to the options Build & Run and added a new kit with the following values

    Name: Qt 5.9.1
    File System name: *empty*
    Device Type: Desktop
    Device: Local Pc (default for desktop)
    Sysroot: *empty*
    C: GCC C x86 64bit /usr/bin
    C++: GCC C++ x86 64bit /usr/bin
    Environment: *has a non changable value* No changes to apply
    Debugger: System GDB at /usr/bin/gdb
    Qt Version: Qt 5.9.1 (build_qt5)
    Qt mkspec: *empty*
    CMake Tool: System CMake at /usr/bin/cmake

    Now the DB connection seems to work but when i do

    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
        bool ok =;
        QSqlQueryModel *model = new QSqlQueryModel;
        model->setQuery("SELECT id, comment, pdf FROM pdf");
        model->setHeaderData(0, Qt::Horizontal, tr("id"));
        model->setHeaderData(1, Qt::Horizontal, tr("comment"));
        model->setHeaderData(2, Qt::Horizontal, tr("pdf"));
        QTableView *view = new QTableView;

    (cent is a layout i added in the form just for debug purpose) Nothing appears and i get an error saying that Qt didnt ship anymore with font database or something so i went ahead and created a fonts directory in build_qt5/lib i took the font Oxygen from Google fonts. So everything works perfectly thanks a lot for that! I am now looking to add the oxygen font for my overall application but i should be able to figure that out alone.

    Again thanks alot!

Log in to reply