MySQL + Qt 5.7 integration on Ubuntu 16.04



  • Hi,
    I'm new in forum and a beginner in Qt as well.
    I know this issue has been asked several times in other threads but I'm struggling with this for almost 3 days without success. I can say that i went through this forum from top to bottom, trying all procedures indicated in related posts.
    I hardly ever make any posts. If I'm in trouble, i read and try possible solutions from all related topics i find. But this time i really don't know what to do.

    Explaining what I'm facing:
    I'm trying follow along a section of a book concerning integration between connection to databases using mysql and Qt5. All instructions are for windows users.

    Running the following C++:

    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
        db.setHostName("localhost");
        db.setUserName("guilherme");
        db.setPassword("12345678");
        db.setDatabaseName("dbTest");
        if(db.open()) {
            QSqlQuery query;
            if(query.exec("SELECT name, age, gender, married FROM tableTest")) {
                while (query.next()) {
                    qDebug() << query.value(0)
                             << query.value(1)
                             << query.value(2)
                             << query.value(3);
                    ui->name->setText(query.value(0).toString());
                    ui->age->setText(query.value(1).toString());
                    ui->gender->setCurrentIndex(query.value(2).toInt());
                    ui->married->setChecked(query.value(3).toBool());
                }
            }
            else {
                qDebug() << query.lastError().text();
            }
        }
    

    I get the driver not loaded thing:

    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
    

    By reading everyone else's same problem i know the issue is related to library dependency lack, as ldd in my plugins driver folder points out:

    guilherme@k45a:~/Programs/Qt/5.7/gcc_64/plugins/sqldrivers$ ldd libqsqlmysql.so
    linux-vdso.so.1 => (0x00007fffed9fc000)
    libmysqlclient_r.so.16 => not found
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f39db87f000)
    libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007f39db646000)
    libnsl.so.1 => /lib/x86_64-linux-gnu/libnsl.so.1 (0x00007f39db42d000)
    libssl.so.10 => not found
    libcrypto.so.10 => not found
    libQt5Sql.so.5 => /home/guilherme/Programs/Qt/5.7/gcc_64/plugins/sqldrivers/./../../lib/libQt5Sql.so.5 (0x00007f39db1e7000)
    libQt5Core.so.5 => /home/guilherme/Programs/Qt/5.7/gcc_64/plugins/sqldrivers/./../../lib/libQt5Core.so.5 (0x00007f39daac9000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f39da8ab000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f39da529000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f39da220000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f39da009000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f39d9c40000)
    libicui18n.so.56 => /home/guilherme/Programs/Qt/5.7/gcc_64/plugins/sqldrivers/./../../lib/libicui18n.so.56 (0x00007f39d97a5000)
    libicuuc.so.56 => /home/guilherme/Programs/Qt/5.7/gcc_64/plugins/sqldrivers/./../../lib/libicuuc.so.56 (0x00007f39d93ed000)
    libicudata.so.56 => /home/guilherme/Programs/Qt/5.7/gcc_64/plugins/sqldrivers/./../../lib/libicudata.so.56 (0x00007f39d7a0a000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f39d7806000)
    libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007f39d7603000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f39d73fb000)
    libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f39d70ea000)
    /lib64/ld-linux-x86-64.so.2 (0x000055d6bdb14000)
    libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f39d6e79000)

    As other requirement, i placed libqsqlite.so libqsqlmysql.so libqsqlodbc.so libqsqlpsql.so
    in my application's debug build folder, under sqldrivers.

    At this point I'm suck.
    I already tried compiling the plugin with qmake, but i receive an error in make's recipe as well. The fact is that i'm not sure if i'm doing it right and even if it's right, i know that i cannot simply skip those 3 libraries fault above.

    Can anyone please give me any directions on how to work around this problem?
    Any help will be appreciated.

    Thank you!


  • Moderators

    @ErranusCaminhus This problem has been answered several times on this forum. Try using the search functionality of the forum. Here's one that might help:
    https://forum.qt.io/topic/59449/qsqldatabase-qmysql-driver-not-loaded-build-mysql-plugin


  • Qt Champions 2016

    Hi
    It seems it cant find libmysqlclient_r.so.16
    ( the actual mysql client so file)

    IF you see this post
    https://forum.qt.io/topic/59449/qsqldatabase-qmysql-driver-not-loaded-build-mysql-plugin/2

    Seems to be exact same issue.

    libmysqlclient_r.so.16 => not found

    So you did rebuild the plugin ? So it will use your installed client so-s ?
    http://doc.qt.io/qt-5/sql-driver.html

    Update: @p3c0 beat me to it :) so info is redundant but still important if you rebuild the plugin or not.



  • @p3c0 said in MySQL + Qt 5.7 integration on Ubuntu 16.04:

    @ErranusCaminhus This problem has been answered several times on this forum. Try using the search functionality of the forum. Here's one that might help:
    https://forum.qt.io/topic/59449/qsqldatabase-qmysql-driver-not-loaded-build-mysql-plugin

    Hi, really appreciate your quick response!
    As I stated, I read many of the topics with related issues and tried all possible combination of solutions. Bit I gave it another try!

    Following step-bystep guide from user mattewre:

    • Clean Ubuntu 14.04 installation: OK
      Installed QT in the user Home: OK
      During the installation select all "Source Components": OK
      Install a compiler: OK
      Write you project and you will face problems with: db = QsqlDatabase::addDatabase("QMYSQL"); OK (As can be seen in first post)
    • Read this line of the output: libmysqlclient_r.so.16 => not found. (Still not found.)

    guilherme@k45a:~/Programs/Qt/5.7/gcc_64/plugins/sqldrivers$ ldd libqsqlmysql.so
    linux-vdso.so.1 => (0x00007fff16edf000)
    libmysqlclient_r.so.16 => /usr/lib/x86_64-linux-gnu/libmysqlclient_r.so.16 (0x00007f92ac8da000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f92ac6c0000)
    libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007f92ac487000)
    libnsl.so.1 => /lib/x86_64-linux-gnu/libnsl.so.1 (0x00007f92ac26e000)
    libssl.so.10 => not found
    libcrypto.so.10 => not found

    libQt5Sql.so.5 => /home/guilherme/Programs/Qt/5.7/gcc_64/plugins/sqldrivers/./../../lib/libQt5Sql.so.5 (0x00007f92ac028000)
    libQt5Core.so.5 => /home/guilherme/Programs/Qt/5.7/gcc_64/plugins/sqldrivers/./../../lib/libQt5Core.so.5 (0x00007f92ab90a000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f92ab6ec000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f92ab36a000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f92ab061000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f92aae4a000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f92aaa81000)
    libicui18n.so.56 => /home/guilherme/Programs/Qt/5.7/gcc_64/plugins/sqldrivers/./../../lib/libicui18n.so.56 (0x00007f92aa5e6000)
    libicuuc.so.56 => /home/guilherme/Programs/Qt/5.7/gcc_64/plugins/sqldrivers/./../../lib/libicuuc.so.56 (0x00007f92aa22e000)
    libicudata.so.56 => /home/guilherme/Programs/Qt/5.7/gcc_64/plugins/sqldrivers/./../../lib/libicudata.so.56 (0x00007f92a884b000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f92a8646000)
    libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007f92a8444000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f92a823c000)
    libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f92a7f2a000)
    /lib64/ld-linux-x86-64.so.2 (0x000055e897bba000)
    libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f92a7cba000)

    • Now you should build the MYSQL plugin, according to http://doc.qt.io/qt-5/sql-driver.html documentation:
      cd /home/[yourUsername]/Qt/[QtVersion]/Src/qtbase/src/plugins/sqldrivers/mysql
      Then use the qmake provided in your Qt5.5 installation
      /home/[yourUsername]/Qt/[QtVersion]/gcc/bin/qmake
      My qmake output: returns error:
      guilherme@k45a:~/Programs/Qt/5.7/Src/qtbase/src/plugins/sqldrivers/mysql$ make
      /home/guilherme/Programs/Qt/5.7/gcc_64/bin/moc -DQT_NO_MTDEV -DQT_NO_LIBUDEV -DQT_NO_TSLIB -DQT_NO_LIBINPUT -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -I/home/guilherme/Programs/Qt/5.7/Src/qtbase/mkspecs/linux-g++ -I/home/guilherme/Programs/Qt/5.7/Src/qtbase/src/plugins/sqldrivers/mysql -I/home/guilherme/Programs/Qt/5.7/gcc_64/include/QtSql/5.7.1 -I/home/guilherme/Programs/Qt/5.7/gcc_64/include/QtSql/5.7.1/QtSql -I/home/guilherme/Programs/Qt/5.7/gcc_64/include/QtCore/5.7.1 -I/home/guilherme/Programs/Qt/5.7/gcc_64/include/QtCore/5.7.1/QtCore -I/home/guilherme/Programs/Qt/5.7/gcc_64/include -I/home/guilherme/Programs/Qt/5.7/gcc_64/include/QtSql -I/home/guilherme/Programs/Qt/5.7/gcc_64/include/QtCore -I/usr/include/c++/5 -I/usr/include/x86_64-linux-gnu/c++/5 -I/usr/include/c++/5/backward -I/usr/lib/gcc/x86_64-linux-gnu/5/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include main.cpp -o .moc/main.moc
      g++ -c -pipe -I/usr/include/mysql -O2 -std=c++1y -fvisibility=hidden -fvisibility-inlines-hidden -fno-exceptions -Wall -W -Wvla -D_REENTRANT -fPIC -DQT_NO_MTDEV -DQT_NO_LIBUDEV -DQT_NO_TSLIB -DQT_NO_LIBINPUT -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -I. -I/home/guilherme/Programs/Qt/5.7/gcc_64/include/QtSql/5.7.1 -I/home/guilherme/Programs/Qt/5.7/gcc_64/include/QtSql/5.7.1/QtSql -I/home/guilherme/Programs/Qt/5.7/gcc_64/include/QtCore/5.7.1 -I/home/guilherme/Programs/Qt/5.7/gcc_64/include/QtCore/5.7.1/QtCore -I/home/guilherme/Programs/Qt/5.7/gcc_64/include -I/home/guilherme/Programs/Qt/5.7/gcc_64/include/QtSql -I/home/guilherme/Programs/Qt/5.7/gcc_64/include/QtCore -I.moc -I../../../../mkspecs/linux-g++ -o .obj/main.o main.cpp
      g++ -c -pipe -I/usr/include/mysql -O2 -std=c++1y -fvisibility=hidden -fvisibility-inlines-hidden -fno-exceptions -Wall -W -Wvla -D_REENTRANT -fPIC -DQT_NO_MTDEV -DQT_NO_LIBUDEV -DQT_NO_TSLIB -DQT_NO_LIBINPUT -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -I. -I/home/guilherme/Programs/Qt/5.7/gcc_64/include/QtSql/5.7.1 -I/home/guilherme/Programs/Qt/5.7/gcc_64/include/QtSql/5.7.1/QtSql -I/home/guilherme/Programs/Qt/5.7/gcc_64/include/QtCore/5.7.1 -I/home/guilherme/Programs/Qt/5.7/gcc_64/include/QtCore/5.7.1/QtCore -I/home/guilherme/Programs/Qt/5.7/gcc_64/include -I/home/guilherme/Programs/Qt/5.7/gcc_64/include/QtSql -I/home/guilherme/Programs/Qt/5.7/gcc_64/include/QtCore -I.moc -I../../../../mkspecs/linux-g++ -o .obj/qsql_mysql.o ../../../sql/drivers/mysql/qsql_mysql.cpp
      /home/guilherme/Programs/Qt/5.7/gcc_64/bin/moc -DQT_NO_MTDEV -DQT_NO_LIBUDEV -DQT_NO_TSLIB -DQT_NO_LIBINPUT -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -I/home/guilherme/Programs/Qt/5.7/Src/qtbase/mkspecs/linux-g++ -I/home/guilherme/Programs/Qt/5.7/Src/qtbase/src/plugins/sqldrivers/mysql -I/home/guilherme/Programs/Qt/5.7/gcc_64/include/QtSql/5.7.1 -I/home/guilherme/Programs/Qt/5.7/gcc_64/include/QtSql/5.7.1/QtSql -I/home/guilherme/Programs/Qt/5.7/gcc_64/include/QtCore/5.7.1 -I/home/guilherme/Programs/Qt/5.7/gcc_64/include/QtCore/5.7.1/QtCore -I/home/guilherme/Programs/Qt/5.7/gcc_64/include -I/home/guilherme/Programs/Qt/5.7/gcc_64/include/QtSql -I/home/guilherme/Programs/Qt/5.7/gcc_64/include/QtCore -I/usr/include/c++/5 -I/usr/include/x86_64-linux-gnu/c++/5 -I/usr/include/c++/5/backward -I/usr/lib/gcc/x86_64-linux-gnu/5/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include ../../../sql/drivers/mysql/qsql_mysql_p.h -o .moc/moc_qsql_mysql_p.cpp
      g++ -c -pipe -I/usr/include/mysql -O2 -std=c++1y -fvisibility=hidden -fvisibility-inlines-hidden -fno-exceptions -Wall -W -Wvla -D_REENTRANT -fPIC -DQT_NO_MTDEV -DQT_NO_LIBUDEV -DQT_NO_TSLIB -DQT_NO_LIBINPUT -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -I. -I/home/guilherme/Programs/Qt/5.7/gcc_64/include/QtSql/5.7.1 -I/home/guilherme/Programs/Qt/5.7/gcc_64/include/QtSql/5.7.1/QtSql -I/home/guilherme/Programs/Qt/5.7/gcc_64/include/QtCore/5.7.1 -I/home/guilherme/Programs/Qt/5.7/gcc_64/include/QtCore/5.7.1/QtCore -I/home/guilherme/Programs/Qt/5.7/gcc_64/include -I/home/guilherme/Programs/Qt/5.7/gcc_64/include/QtSql -I/home/guilherme/Programs/Qt/5.7/gcc_64/include/QtCore -I.moc -I../../../../mkspecs/linux-g++ -o .obj/moc_qsql_mysql_p.o .moc/moc_qsql_mysql_p.cpp
      rm -f libqsqlmysql.so
      g++ -Wl,--no-undefined -Wl,-O1 -Wl,--enable-new-dtags -Wl,-z,origin -Wl,-rpath,$ORIGIN/../../lib -Wl,-rpath,$ORIGIN/../../lib -shared -o libqsqlmysql.so .obj/main.o .obj/qsql_mysql.o .obj/moc_qsql_mysql_p.o -L/usr/lib64/mysql -lmysqlclient_r -lz -lcrypt -lnsl -lm -lssl -lcrypto -L/home/guilherme/Programs/Qt/5.7/gcc_64/lib -lQt5Sql -lQt5Core -lpthread
      /usr/bin/ld: cannot find -lmysqlclient_r
      collect2: error: ld returned 1 exit status
      Makefile:114: recipe for target '../../../../plugins/sqldrivers/libqsqlmysql.so' failed
      make: *** [../../../../plugins/sqldrivers/libqsqlmysql.so] Error 1
    • And make output:
      guilherme@k45a:~/Programs/Qt/5.7/Src/qtbase/src/plugins/sqldrivers/mysql$ make
      rm -f libqsqlmysql.so
      g++ -Wl,--no-undefined -Wl,-O1 -Wl,--enable-new-dtags -Wl,-z,origin -Wl,-rpath,$ORIGIN/../../lib -Wl,-rpath,$ORIGIN/../../lib -shared -o libqsqlmysql.so .obj/main.o .obj/qsql_mysql.o .obj/moc_qsql_mysql_p.o -L/usr/lib64/mysql -lmysqlclient_r -lz -lcrypt -lnsl -lm -lssl -lcrypto -L/home/guilherme/Programs/Qt/5.7/gcc_64/lib -lQt5Sql -lQt5Core -lpthread
      /usr/bin/ld: cannot find -lmysqlclient_r
      collect2: error: ld returned 1 exit status
      Makefile:114: recipe for target '../../../../plugins/sqldrivers/libqsqlmysql.so' failed
      make: *** [../../../../plugins/sqldrivers/libqsqlmysql.so] Error 1
    • make install returns error pointed out by the guide:
      guilherme@k45a:~/Programs/Qt/5.7/Src/qtbase/src/plugins/sqldrivers/mysql$ make install
      rm -f libqsqlmysql.so
      g++ -Wl,--no-undefined -Wl,-O1 -Wl,--enable-new-dtags -Wl,-z,origin -Wl,-rpath,$ORIGIN/../../lib -Wl,-rpath,$ORIGIN/../../lib -shared -o libqsqlmysql.so .obj/main.o .obj/qsql_mysql.o .obj/moc_qsql_mysql_p.o -L/usr/lib64/mysql -lmysqlclient_r -lz -lcrypt -lnsl -lm -lssl -lcrypto -L/home/guilherme/Programs/Qt/5.7/gcc_64/lib -lQt5Sql -lQt5Core -lpthread
      /usr/bin/ld: cannot find -lmysqlclient_r
      collect2: error: ld returned 1 exit status
      Makefile:114: recipe for target '../../../../plugins/sqldrivers/libqsqlmysql.so' failed
      make: *** [../../../../plugins/sqldrivers/libqsqlmysql.so] Error 1
    • Make some symbolic links to make it working (please check mysql version, it could not be 18.1.0 in the future):
      sudo ln -s /usr/lib/i386-linux-gnu/libmysqlclient.so /usr/lib/i386-linux-gnu/libmysqlclient_r.so
      guilherme@k45a:~$ sudo ln -s /usr/lib/i386-linux-gnu/libmysqlclient.so /usr/lib/i386-linux-gnu/libmysqlclient_r.so
      ln: failed to create symbolic link '/usr/lib/i386-linux-gnu/libmysqlclient_r.so': File exists
      sudo ln -s /usr/lib/i386-linux-gnu/libmysqlclient.so /usr/lib/i386-linux-gnu/libmysqlclient_r.so.18
      OK
      sudo ln -s /usr/lib/i386-linux-gnu/libmysqlclient.so /usr/lib/i386-linux-gnu/libmysqlclient_r.so.18.1.0
      OK
    • Runing again make i have the same errors:
      make
      It seems that the plugin have been built correctly. Last output is:
      mv -f libqsqlmysql.so ../../../../plugins/sqldrivers/
      and finally run:
      make install
      guilherme@k45a:~/Programs/Qt/5.7/Src/qtbase/src/plugins/sqldrivers/mysql$ make
      rm -f libqsqlmysql.so
      g++ -Wl,--no-undefined -Wl,-O1 -Wl,--enable-new-dtags -Wl,-z,origin -Wl,-rpath,$ORIGIN/../../lib -Wl,-rpath,$ORIGIN/../../lib -shared -o libqsqlmysql.so .obj/main.o .obj/qsql_mysql.o .obj/moc_qsql_mysql_p.o -L/usr/lib64/mysql -lmysqlclient_r -lz -lcrypt -lnsl -lm -lssl -lcrypto -L/home/guilherme/Programs/Qt/5.7/gcc_64/lib -lQt5Sql -lQt5Core -lpthread
      /usr/bin/ld: cannot find -lmysqlclient_r
      collect2: error: ld returned 1 exit status
      Makefile:114: recipe for target '../../../../plugins/sqldrivers/libqsqlmysql.so' failed
      make: *** [../../../../plugins/sqldrivers/libqsqlmysql.so] Error 1
      guilherme@k45a:~/Programs/Qt/5.7/Src/qtbase/src/plugins/sqldrivers/mysql$ make install
      rm -f libqsqlmysql.so
      g++ -Wl,--no-undefined -Wl,-O1 -Wl,--enable-new-dtags -Wl,-z,origin -Wl,-rpath,$ORIGIN/../../lib -Wl,-rpath,$ORIGIN/../../lib -shared -o libqsqlmysql.so .obj/main.o .obj/qsql_mysql.o .obj/moc_qsql_mysql_p.o -L/usr/lib64/mysql -lmysqlclient_r -lz -lcrypt -lnsl -lm -lssl -lcrypto -L/home/guilherme/Programs/Qt/5.7/gcc_64/lib -lQt5Sql -lQt5Core -lpthread
      /usr/bin/ld: cannot find -lmysqlclient_r
      collect2: error: ld returned 1 exit status
      Makefile:114: recipe for target '../../../../plugins/sqldrivers/libqsqlmysql.so' failed
      make: *** [../../../../plugins/sqldrivers/libqsqlmysql.so] Error 1

    And still getting "driver not loaded".

    Do you have any other suggestion?



  • @mrjj said in MySQL + Qt 5.7 integration on Ubuntu 16.04:

    Hi
    It seems it cant find libmysqlclient_r.so.16
    ( the actual mysql client so file)
    IF you see this post
    https://forum.qt.io/topic/59449/qsqldatabase-qmysql-driver-not-loaded-build-mysql-plugin/2
    Seems to be exact same issue.
    libmysqlclient_r.so.16 => not found
    So you did rebuild the plugin ? So it will use your installed client so-s ?
    http://doc.qt.io/qt-5/sql-driver.html
    Update: @p3c0 beat me to it :) so info is redundant but still important if you rebuild the plugin or not.

    Hi! @mrjj. I appreciate you reply!
    After installing libmysqlclient deb package supplied in the step-by-step post, i can see now that libmysqlclient_r.so.16 doesn't have dependency not found anymore, but i have the same fault for the other 2 libraries:
    libssl.so.10 => not found
    libcrypto.so.10 => not found

    After that, following along the step-by-step, even if i have libmysqlclient present, qmake and make are still throwing errors which i described in the last post.
    Actually i'm not certain if i rebuilt the plugin as you suggested.
    Do you mean qmake and make results?
    Could you elaborate on that or do you have any other suggestion?

    Thank you!


  • Moderators

    Depending upon your distro install libssl package.



  • @p3c0 said in MySQL + Qt 5.7 integration on Ubuntu 16.04:

    Depending upon your distro install libssl package.

    @p3c0

    Yes. Sure i have. See:

    guilherme@k45a:~$ dpkg --get-selections | grep libssl
    libssl-dev:amd64 install
    libssl-doc install
    libssl1.0.0:amd64 install
    libssl1.0.0:i386 install


  • Qt Champions 2016

    Hi
    Yes, it seems you build it.
    Makefile:114: recipe for target '../../../../plugins/sqldrivers/libqsqlmysql.so' failed
    Also +10 for actually reading the posts and try first :)

    There still seems to be a build issue
    /usr/bin/ld: cannot find -lmysqlclient_r

    -lmysqlclient_r

    Its 100% sure its not -llibmysqlclient_r ?

    Im not that used to linux so im afraid i would not spot path mismatches and such things

    Others here might have better suggestions to this fine output :)


  • Lifetime Qt Champion

    Hi,

    Unless I misread, you didn't install the development package neither for MySQL nor OpenSSL.


  • Qt Champions 2016

    @SGaist

    Would that be these ?
    Install these packages
    sudo apt-get install libssl-dev
    sudo apt-get install libmysqlclient-dev
    Thank you



  • @mrjj said in MySQL + Qt 5.7 integration on Ubuntu 16.04:

    Hi
    Yes, it seems you build it.
    Makefile:114: recipe for target '../../../../plugins/sqldrivers/libqsqlmysql.so' failed
    Also +10 for actually reading the posts and try first :)
    There still seems to be a build issue
    /usr/bin/ld: cannot find -lmysqlclient_r
    -lmysqlclient_r
    Its 100% sure its not -llibmysqlclient_r ?
    Im not that used to linux so im afraid i would not spot path mismatches and such things
    Others here might have better suggestions to this fine output :)

    Thank you!
    I'm happy to say that i feel like the cast away of the movie after making fire!
    Just managed to solve this issue.

    Based on this topic: http://askubuntu.com/questions/772024/cannot-compile-qt-5-6-0-mysql-plugin-in-ubuntu-16-04-lts-64bit, what i did was to create one more link:

    guilherme@k45a:~$ sudo ln -s /usr/lib/x86_64-linux-gnu/libmysqlclient.so /usr/lib/x86_64-linux-gnu/libmysqlclient_r.so

    After that, qmake, make and make install went well with no errors!

    I hope this thread help people with the same problem.
    Thanks for all the assistance!


  • Lifetime Qt Champion

    Indeed, however I did misread, the calls seem to have been done.

    But something looks wrong since the .so files can't be found.



  • @SGaist

    @SGaist said in MySQL + Qt 5.7 integration on Ubuntu 16.04:

    Indeed, however I did misread, the calls seem to have been done.
    But something looks wrong since the .so files can't be found.

    Interesting to see what ldd on libqsqlmysql.so displays now, after creating the link:

    guilherme@k45a:~/Programs/Qt/5.7/gcc_64/plugins/sqldrivers$ ldd libqsqlmysql.so
    linux-vdso.so.1 => (0x00007ffe33d5f000)
    libmysqlclient.so.20 => /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20 (0x00007f8c1fcb1000)
    libQt5Sql.so.5 => /home/guilherme/Programs/Qt/5.7/gcc_64/plugins/sqldrivers/./../../lib/libQt5Sql.so.5 (0x00007f8c1fa6c000)
    libQt5Core.so.5 => /home/guilherme/Programs/Qt/5.7/gcc_64/plugins/sqldrivers/./../../lib/libQt5Core.so.5 (0x00007f8c1f34d000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f8c1efcb000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f8c1ec02000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f8c1e9e7000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f8c1e7e3000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f8c1e5c6000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f8c1e2bc000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f8c1e0a6000)
    libicui18n.so.56 => /home/guilherme/Programs/Qt/5.7/gcc_64/plugins/sqldrivers/./../../lib/libicui18n.so.56 (0x00007f8c1dc0b000)
    libicuuc.so.56 => /home/guilherme/Programs/Qt/5.7/gcc_64/plugins/sqldrivers/./../../lib/libicuuc.so.56 (0x00007f8c1d853000)
    libicudata.so.56 => /home/guilherme/Programs/Qt/5.7/gcc_64/plugins/sqldrivers/./../../lib/libicudata.so.56 (0x00007f8c1be70000)
    libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007f8c1bc6d000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f8c1ba65000)
    libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f8c1b754000)
    /lib64/ld-linux-x86-64.so.2 (0x000055a9c6cac000)
    libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f8c1b4e3000)

    Seems like it changed the entire dependency table.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.