Qt 5.1.0 and MySQL 5.5.32 "Driver not loaded"
-
wrote on 16 Jul 2013, 00:44 last edited by
Can you test what is the result of this?
@
qDebug() << "drivers: "<< QSqlDatabase::drivers();@ -
wrote on 16 Jul 2013, 01:06 last edited by
Yes. I can :)
( "QSQLITE", "QMYSQL", "QMYSQL3", "QPSQL", "QPSQL7" )
So.. All drivers present, known and ready. There is only no action.. :(
-
wrote on 16 Jul 2013, 11:40 last edited by
When driver is in list and it not work fine, i then replace .so file with new compiled .so in qt5 plugins directory and it all times works fine.
Check this from terminal:
@sudo cp /home/youruser/yourbuilddirectory/qsqlmysql.so /yourqt5directory/gcc/plugins/sqldrivers/@
Or do it manualy in nautilus with sudo privileges
If compiled driver .so file is in this directory it works correctly all times.
If you do it and it not work fine i think the problem is in your .so. In this case recompile it and check if are fine compiled and replace .so again.
-
wrote on 21 Jul 2013, 08:27 last edited by
@PeterMGroen
you dont need to compile the plugin. it comes with the package you downloaded under ~/Qt/5.1.0/gcc_64/plugins/sqldrivers/libqsqlmysql.so
that's why you see "QMYSQL" when you run QSqlDatabase::drivers();
do you have the mysql devel package installed ?
it works for me out of the box from Fedora 16 to Fedora 18.
-
wrote on 30 Aug 2013, 17:13 last edited by
I had the same issue with Qt 5.1.1.
The included libqsqlmysql.so driver appears to be linked against an incompatible libmysqlclient when using mariadb.
I haven't found a solution yet which doesn't involve rebuilding Qt from scratch.
(Rebuilding just the Sql module appears to link the mysql driver code into libQt5Sql.so which isn't what I want...)
-
wrote on 30 Aug 2013, 17:16 last edited by
mmm .. I am not sure if this is supposed to work with MariaDB out of the box ..
which MariaDB packages did you install ?
when you rebuilt Qt .. which configure option did you use ? did you use -plugin-sql-mysql ?
-
wrote on 27 Nov 2013, 04:43 last edited by
I have the same problem like PeterMGroen.
QT: online installation.
OS: ubuntu desktop 12.04
Mysql: 5.5I made @ldd libqsqlmysql.so@ and saw that it cannot find one lib file. So I compiled new libqsqlmysql.so and place it sqldrivers folder of qt env.
also made copy of it to "application folder/sqldrivers" folder. Not success. -
wrote on 4 Dec 2013, 07:38 last edited by
Hello everybody!
I had the same problem on Debian 7. Solve is - use QPluginLoader.
@QPluginLoader loader("path-to-your-driver/libqsqlmysql.so");
loader.load();
qDebug() << loader.errorString();@So, it said to me that I had not one library. I installed it, and all works now!
-
wrote on 4 Dec 2013, 09:48 last edited by
[quote author="vtyulb" date="1386142729"]Hello everybody!
I had the same problem on Debian 7. Solve is - use QPluginLoader.
@QPluginLoader loader("path-to-your-driver/libqsqlmysql.so");
loader.load();
qDebug() << loader.errorString();@So, it said to me that I had not one library. I installed it, and all works now![/quote]
I tried, but got this message:
@"Unknown error"
drivers: ("QSQLITE", "QMYSQL", "QMYSQL3", "QPSQL", "QPSQL7")
"Driver not loaded Driver not loaded" @My connection code is
@db = new QSqlDatabase();
db->addDatabase("QMYSQL", "DB");
db->setHostName("localhost");
db->setDatabaseName("myclinic");
db->setUserName("root");
db->setPassword(",trth12");QPluginLoader loader("./sqldrivers/libqsqlmysql.so"); loader.load(); qDebug() << loader.errorString(); qDebug() << "drivers: "<< QSqlDatabase::drivers(); if (db->open()) qDebug() << "Success!"; else qDebug() << db->lastError().text();
@
-
wrote on 4 Dec 2013, 15:07 last edited by
I think it is a good idea to move sqldrivers to folder "plugins".
@vlad@vtyulb:~/server$ ls
config.ini plugins Server
vlad@vtyulb:~/server$ ls plugins/sqldrivers/
libqsqlmysql.so
@ -
wrote on 5 Dec 2013, 02:27 last edited by
[quote author="vtyulb" date="1386169653"]I think it is a good idea to move sqldrivers to folder "plugins".
@vlad@vtyulb:~/server$ ls
config.ini plugins Server
vlad@vtyulb:~/server$ ls plugins/sqldrivers/
libqsqlmysql.so
@[/quote]I don't understand what you mean.
For me it seems the problem is qt see mysql driver, but can not load. The error message as I show above is "Unknown error". -
wrote on 5 Dec 2013, 09:33 last edited by
As I know:
Qt by default search plugins at directory "./plugins/"
So, right tree:
./binary-file
./plugins/sqldrivers/libqsqlmysql.soI didn't work with QPluginLoader, but I think, that "Unknown error" means that everything OK. When I installed library, I got this message.
So, I think it is a good idea to remove QPluginLoader from code, and
improve filesystem tree. -
wrote on 5 Dec 2013, 10:01 last edited by
ok, I tried your advice before, but I am going to try it again.
-
wrote on 5 Dec 2013, 10:11 last edited by
Any changes. I removed QPluginLoader object, but the error "Driver not loaded" remain.
It makes me crazy, I am spending about 1 week to solve this issue, and not solved it yet.I saw suggestions for windows platforms to copy libmysql.dll in project root directory. What is the name of this file in linux?
-
wrote on 5 Dec 2013, 11:26 last edited by
[quote author="kalempir" date="1386238296"]Any changes. I removed QPluginLoader object, but the error "Driver not loaded" remain.
It makes me crazy, I am spending about 1 week to solve this issue, and not solved it yet.I saw suggestions for windows platforms to copy libmysql.dll in project root directory. What is the name of this file in linux?[/quote]
I think libmysql.dll == libmysqlclient_r.so.
But if QPluginLoader loads plugin without problems, it is very strange, that Qt can't load it.Here is my connection code:
@QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("localhost");
db.setDatabaseName("safecloud");
db.setUserName(mySqlLogin);
db.setPassword(mySqlPassword);
@I got another idea. If you compile program on one system and copy it to another, it can be a situation:
On target system there is Qt of another version. It has plugins, but incompatible versions. When you start program, it searches for plugins. It finds plugins in Qt on target system, but if versions of Qt are different, it can't load it.So, if there is a Qt on target system, you can try to do command like this:
@cp ./plugins/sqldrivers/libqsqlmsql.so /opt/Qt/5.1.1/gcc_64/plugins/sqldrivers/libqsqlmysql.so@
Are you compile and run program on the same systems?
-
wrote on 5 Dec 2013, 12:53 last edited by
[quote author="vtyulb" date="1386242785"]
I think libmysql.dll == libmysqlclient_r.so.
But if QPluginLoader loads plugin without problems, it is very strange, that Qt can't load it.
Here is my connection code:
@QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("localhost");
db.setDatabaseName("safecloud");
db.setUserName(mySqlLogin);
db.setPassword(mySqlPassword);
@I got another idea. If you compile program on one system and copy it to another, it can be a situation:
On target system there is Qt of another version. It has plugins, but incompatible versions. When you start program, it searches for plugins. It finds plugins in Qt on target system, but if versions of Qt are different, it can't load it.So, if there is a Qt on target system, you can try to do command like this:
@cp ./plugins/sqldrivers/libqsqlmsql.so /opt/Qt/5.1.1/gcc_64/plugins/sqldrivers/libqsqlmysql.so@
Are you compile and run program on the same systems?[/quote]
Yes, I compiled and run program in the same system.
System is Ubuntu Desktop 12.04, 32 bit.
When I try to compile mysql driver by QtCreator, I get error
@mv -f libqsqlmysql.so /plugins/sqldrivers/
mv: cannot movelibqsqlmysql.so' to
/plugins/sqldrivers/libqsqlmysql.so': Permission denied
{ test -z "/plugins/sqldrivers/" || cd "/plugins/sqldrivers/"; } && test $(gdb --version | sed -e 's,[^0-9]+([0-9]).([0-9]).*,\1\2,;q') -gt 72 && gdb --nx --batch --quiet -ex 'set confirm off' -ex "save gdb-index ." -ex quit 'libqsqlmysql.so' && test -f libqsqlmysql.so.gdb-index && objcopy --add-section '.gdb_index=libqsqlmysql.so.gdb-index' --set-section-flags '.gdb_index=readonly' 'libqsqlmysql.so' 'libqsqlmysql.so' && rm -f libqsqlmysql.so.gdb-index || true
make: [/plugins/sqldrivers/libqsqlmysql.so] Error 1 (ignored)@
So, I compile in console and it finished successfully, and the result lib file is placed in needed place. I copied this file to ~/Qt/5.1.1/gcc/plugins/sqldrivers directory. Then copied it to application folder, it didn't work, then created folder named sqldrivers in application folder and copied driver file to there, not success, then made as you said, but again no success.Ok, I thougt that libmysql.dll file is libmysqlclient.so file in linux. So I changed it to libmysqlclient_r.so file, again no success.
QPluginLoader did not loaded mysql driver lib file, it just said that there is a error, "Unknown error".
@QSqlDatabase::drivers()@
show that there is mysql driver file.
@ldd libqsqlmysql.so@
command in console show that all dependencies are ok for that lib file.
-
wrote on 5 Dec 2013, 13:28 last edited by
QPluginLoader says "Unknown error" to me too. So, I think it can load library.
I don't understand what the hell is on your machine.
I have Debian 7.0.
Everything what I do was:- Installed Qt 5.1
- Installed libmysql++3 libmysqlclient-dev libmysql++-dev
- Checked libraries by ldd.
- Installed libicu-dev
- Tryied QPluginLoader to understand, that I had libmysqlclient, but incorrect version.
- Installed this package from Ubuntu (sic!)
Now I removed plugins folder from my Server. So I have single binary file, and it works.
Yet another idea:
- Delete any libraries from your program.
- Try QPluginLoader on ~/Qt/5.1.1/gcc/plugins/sqldrivers/libqsqlmysql.so
It is also strange, that you did not have precompiled plugin, because I had.
-
wrote on 6 Dec 2013, 03:28 last edited by
[quote]It is also strange, that you did not have precompiled plugin, because I had. [/quote]
I had precompiled plugin, but the command ldd show dependency
inconsistency. That's why I compiled it manually.[quote]2) Installed libmysql++3 libmysqlclient-dev libmysql++-dev[/quote]
All these packets are newest in the system.[quote]4) Installed libicu-dev[/quote]
Ok, I did not have this packet, now it has been installed.
But the result is the same, "Driver not loaded Driver not loaded" .[quote]1) Delete any libraries from your program.
2) Try QPluginLoader on ~/Qt/5.1.1/gcc/plugins/sqldrivers/libqsqlmysql.so[/quote]
I did it. This is my connection code
@
db = new QSqlDatabase();
db->addDatabase("QMYSQL");
db->setHostName("localhost");
db->setDatabaseName("myclinic");
db->setUserName("root");
db->setPassword(",trth12");QPluginLoader loader("/home/test/Qt/5.1.1/gcc/plugins/sqldrivers/libqsqlmysql.so"); loader.load(); qDebug() << loader.errorString(); qDebug() << "drivers: "<< QSqlDatabase::drivers(); if (db->open()) qDebug() << "Success!"; else qDebug() << db->lastError().text();@
This is output text
@Starting /home/test/QtProjects/build-MySQLGUI-Desktop_Qt_5_1_0_GCC_32bit-Debug/MySQLGUI...
"Unknown error"
drivers: ("QSQLITE", "QMYSQL", "QMYSQL3", "QPSQL", "QPSQL7")
"Driver not loaded Driver not loaded" @These commands I have done in system console
@test(at)penguin:~/Qt/5.1.1/gcc/plugins/sqldrivers$ ls
libqsqlite.so libqsqlmysql.so libqsqlpsql.so
test(at)penguin:~/Qt/5.1.1/gcc/plugins/sqldrivers$ ldd libqsqlmysql.so
linux-gate.so.1 => (0xb7764000)
libmysqlclient.so.18 => /usr/lib/i386-linux-gnu/libmysqlclient.so.18 (0xb741e000)
libQt5Sql.so.5 => /home/test/Qt/5.1.1/gcc/lib/libQt5Sql.so.5 (0xb73de000)
libQt5Core.so.5 => /home/test/Qt/5.1.1/gcc/lib/libQt5Core.so.5 (0xb6f5a000)
libstdc++.so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6 (0xb6e75000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb6ccb000)
libz.so.1 => /lib/i386-linux-gnu/libz.so.1 (0xb6cb5000)
libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xb6cb0000)
libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xb6c94000)
libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xb6c68000)
libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0xb6c4a000)
libicui18n.so.51 => /home/test/Qt/5.1.1/gcc/lib/libicui18n.so.51 (0xb6a28000)
libicuuc.so.51 => /home/test/Qt/5.1.1/gcc/lib/libicuuc.so.51 (0xb68af000)
libgthread-2.0.so.0 => /usr/lib/i386-linux-gnu/libgthread-2.0.so.0 (0xb68ab000)
librt.so.1 => /lib/i386-linux-gnu/librt.so.1 (0xb68a2000)
libglib-2.0.so.0 => /lib/i386-linux-gnu/libglib-2.0.so.0 (0xb67a9000)
/lib/ld-linux.so.2 (0xb7765000)
libicudata.so.51 => /home/test/Qt/5.1.1/gcc/lib/libicudata.so.51 (0xb5260000)
libpcre.so.3 => /lib/i386-linux-gnu/libpcre.so.3 (0xb5223000)
test(at)penguin:~/Qt/5.1.1/gcc/plugins/sqldrivers$ @