I Can't able to connect QMYSQL Driver in QT Creator 4.9.2 and QT 5.12.4
-
Hi,
Please help me connect QT with Mysql.
When i tries it showing following error.
OS : Ubuntu 18.04 64 bit
Error :
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7QT : Using Open Source Licence.
I am new to QT and CPP so please guide me step by step.
Thanks in advance.
-
Hi and welcome to devnet,
Please take the time to search this forum for this kind of question, it has been asked many times already.
-
Can you please share some links for that. Because i tried there is all solutions only for windows system but i need ubuntu OS. Thanks in advance.
-
Hi I got this when i runs ldd,
linux-vdso.so.1 (0x00007ffe64dc3000)
libQt5Sql.so.5 => /opt/Qt/5.9/gcc_64/plugins/sqldrivers/./../../lib/libQt5Sql.so.5 (0x00007f0594b18000)
libQt5Core.so.5 => /opt/Qt/5.9/gcc_64/plugins/sqldrivers/./../../lib/libQt5Core.so.5 (0x00007f05943e0000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f05941c1000)
libmysqlclient.so.18 => not found
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f0593e38000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f0593a9a000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f0593882000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f0593491000)
libicui18n.so.56 => /opt/Qt/5.9/gcc_64/plugins/sqldrivers/./../../lib/libicui18n.so.56 (0x00007f0592ff8000)
libicuuc.so.56 => /opt/Qt/5.9/gcc_64/plugins/sqldrivers/./../../lib/libicuuc.so.56 (0x00007f0592c40000)
libicudata.so.56 => /opt/Qt/5.9/gcc_64/plugins/sqldrivers/./../../lib/libicudata.so.56 (0x00007f059125d000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f0591055000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f0590e38000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f0590c34000)
libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007f0590a32000)
libglib-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f059071b000)
/lib64/ld-linux-x86-64.so.2 (0x00007f0594f72000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f05904a9000) -
Well, following the thread I pointed you to, what version of MySQL do you have on your city ?
-
Hi,
Following is my response when i tried qmake please help me.
root@surendar:/opt/Qt/5.9/Src/qtbase/src/plugins/sqldrivers/mysql# qmake "INCLUDEPATH+=/usr/include/mysql" "LIBS+=-L/usr/lib/mysql -lmysqlclient_r" mysql.pro
Project ERROR: Library 'mysql' is not defined. -
So your version of MySQL is way older than the one used to build the Qt plugin.
Two options:
- like already suggested in the thread linked build the plugin against the version of MySQL you have installed.
- use the Qt version provided by your distribution if you don't use any API available in a newer version.
You should also take into account that you are using a 5 years old distribution, you should consider updating.
-
@sgaist said in I Can't able to connect QMYSQL Driver in QT Creator 4.9.2 and QT 5.12.4:
older
I am updating QT 5.9 to 5.13.0
And i got this error when i tried qtbase configure.
Error:
root@surendar:/opt/Qt/5.9/Src/qtbase/src/plugins/sqldrivers/mysql# qmake "INCLUDEPATH+=/usr/include/mysql" "LIBS+=-L/usr/lib/mysql -lmysqlclient_r" mysql.pro
Project ERROR: Library 'mysql' is not defined.Once QT update finished will let you know. Thanks.
-
Don't build as root.
As for building the plugin, follow the related documentation.
-
@surendar-dharani said in I Can't able to connect QMYSQL Driver in QT Creator 4.9.2 and QT 5.12.4:
qmake "INCLUDEPATH+=/usr/include/mysql" "LIBS+=-L/usr/lib/mysql -lmysqlclient_r" mysql.pro
I tried to qmake but it showing follwoing error again, Please help.
acer@surendar:/opt/Qt/5.13.0/Src/qtbase/src/plugins/sqldrivers/mysql$ qmake "INCLUDEPATH+=/usr/include/mysql" "LIBS+=-L/usr/lib/mysql -lmysqlclient_r" mysql.pro
Info: creating stash file /opt/Qt/5.13.0/Src/qtbase/src/plugins/sqldrivers/.qmake.stash
Cannot read /opt/Qt/5.13.0/Src/qtbase/src/plugins/sqldrivers/qtsqldrivers-config.pri: No such file or directory
Project ERROR: Library 'mysql' is not defined. -
Please follow the documentation.
-
Sorry for asking again and again,
I got this error now after i followed the document,
acer@surendar:/opt/Qt/5.13.0/Src/qtbase/src/plugins/sqldrivers/mysql$ make install
make: *** No rule to make target 'install'. Stop.and when i tried ./configure -sql-mysql error is like
ERROR: Feature 'sql-mysql' was enabled, but the pre-condition 'libs.mysql' failed.
-
Please anyone help on this. Thanks a lot in advance
-
Please show some patience before bumping your own thread. People answering here do it voluntarily and might not live in the same time zone as you.
Did you install the MySQL development package from your distribution ?
-
Hi, in most of linux distros, there's not mysql, but mariadb, if this is the case, then you need to make a soft link to mariadb lib and call it like the mysql required
-
@ronaldviscarral Hi,
Thank you very much. Please tell me how to do it by step by step. Because i'm new in this. Thanks in advance.
-
@surendar-dharani sure, first, install mariadb in your linux distro, then as super user in a terminal (for a x64 base system):
ln -s /usr/lib64/libmariadb.so.3 /usr/lib64/libmysqlclient.so.18
you should adapt it to your distro paths and mariadb version
-
@ronaldviscarral said in I Can't able to connect QMYSQL Driver in QT Creator 4.9.2 and QT 5.12.4:
ln -s /usr/lib64/libmariadb.so.3 /usr/lib64/libmysqlclient.so.18
Hi,
I have uninstalled by using following commands and installed maria DB.
sudo apt-get remove --purge mysql-server mysql-client mysql-common
installed mariadb by follwing command,
sudo apt-get install mariadb-serverAnd tried to compile same driver not laoded in mysql
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7Now what to i do?