Problem loading MYSQL/MariaDB Driver in Manjaro Sikaris 22.0
-
wrote on 7 Jan 2023, 06:12 last edited by
Hello,
Recently I've moved from MacOS to Manjaro. When trying to open a MariaDB database, I get:QSqlDatabase: QMARIADB driver not loaded QSqlDatabase: available drivers: QPSQL QMARIADB QMYSQL QSQLITE QODBC
The proyect worked perfectly in MacOS, so I know the code is ok. I've activated the QT_DEBUG_PLUGINS variable, and I get this:
qt.core.library: "/home/santiago/Qt/6.4.2/gcc_64/plugins/sqldrivers/libqsqlmysql.so" cannot load: Cannot load library /home/santiago/Qt/6.4.2/gcc_64/plugins/sqldrivers/libqsqlmysql.so: (libmysqlclient.so.21: cannot open shared object file: No such file or directory) qt.core.plugin.loader: QLibraryPrivate::loadPlugin failed on "/home/santiago/Qt/6.4.2/gcc_64/plugins/sqldrivers/libqsqlmysql.so" : "Cannot load library /home/santiago/Qt/6.4.2/gcc_64/plugins/sqldrivers/libqsqlmysql.so: (libmysqlclient.so.21: cannot open shared object file: No such file or directory)"
I think that the main problem has to do with the way MySQL was installed, but I'm not at all sure. For example, the file called libmysqlclient.so is in /usr/lib/, not in /usr/local/mysql/lib/. Also, the path /usr/mysql/ does not exist.
Could there be a problem with the way I installed MySQL? (I installed it using the command sudo pacman -S mysql).Thanks in advance.
-
wrote on 8 Jan 2023, 06:27 last edited by
Well, I just found how to solve this.
As stated in the output I posted above, the problem it's basically Qt being unable to find libqsqlmysql.so, but thanks to ChatGPT and google searches I found a workaround:- Make sure that you have installed the MySQL client library on your system. You can check if it is installed by running the command locate libmysqlclient.so.21 (in case you are using Linux).
- Make sure that the MySQL driver library is in a location where your Qt application can find it. You can try adding the directory where the MySQL driver library is located to the LD_LIBRARY_PATH environment variable, by running the command: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/mysql/lib
- Then, run Qt from terminal. For example, I do it with this command: ~/Qt/Tools/QtCreator/bin/qtcreator
Thats it, now it should work.
If you don't want to execute the export LD_LIBRARY_PATH=... command everytime before opening Qt, you can set LD_LIBRARY_PATH under environment (Where you add environment variables) . Example:
After your default values in LD_LIBRARY_PATH, add ::/path/to/mysql/lib. If you do this, It's not necessary to open Qt from terminal anymore. -
wrote on 7 Jan 2023, 08:06 last edited by
Hi,
I happen to note the same problem at linux debian system, using Qt6.4 from Qts binary installer.
I did some research and think, that the driver is not ready for mariadb usage.
my error messages are these:
qt.core.plugin.factoryloader: checking directory path "/opt/qt6.4/6.4.1/gcc_64/plugins/sqldrivers" ... qt.core.plugin.factoryloader: looking at "/opt/qt6.4/6.4.1/gcc_64/plugins/sqldrivers/qsqlpsql.debug" qt.core.plugin.factoryloader: "The shared library was not found." not a plugin qt.core.plugin.factoryloader: looking at "/opt/qt6.4/6.4.1/gcc_64/plugins/sqldrivers/qsqlmysql.debug" qt.core.plugin.factoryloader: "The shared library was not found." not a plugin qt.core.plugin.factoryloader: looking at "/opt/qt6.4/6.4.1/gcc_64/plugins/sqldrivers/libqsqlmysql.so" qt.core.plugin.loader: Found metadata in lib /opt/qt6.4/6.4.1/gcc_64/plugins/sqldrivers/libqsqlmysql.so, metadata= { "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface", "MetaData": { "Keys": [ "QMYSQL", "QMARIADB" ] }, "archlevel": 1, "className": "QMYSQLDriverPlugin", "debug": false, "version": 394240 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QMYSQL", "QMARIADB")
but when I look at the cited directory, it contains the named lib:
ls -l /opt/qt6.4/6.4.1/gcc_64/plugins/sqldrivers insgesamt 16260 -rwxr-xr-x 1 user user 1401600 8. Nov 11:51 libqsqlite.so -rwxr-xr-x 1 user user 94856 8. Nov 11:51 libqsqlmysql.so -rwxr-xr-x 1 user user 110760 8. Nov 11:51 libqsqlodbc.so -rwxr-xr-x 1 user user 102920 8. Nov 11:51 libqsqlpsql.so -rw-r--r-- 1 user user 9432120 8. Nov 11:48 qsqlite.debug -rw-r--r-- 1 user user 1739456 8. Nov 11:48 qsqlmysql.debug -rw-r--r-- 1 user user 1801824 8. Nov 11:48 qsqlodbc.debug -rw-r--r-- 1 user user 1947656 8. Nov 11:48 qsqlpsql.debug
so I checked dependencies of mysql library:
/opt/qt6.4/6.4.1/gcc_64/plugins/sqldrivers$ ldd libqsqlmysql.so linux-vdso.so.1 (0x00007ffcfcbdd000) libmysqlclient.so.21 => not found libQt6Sql.so.6 => /opt/qt6.4/6.4.1/gcc_64/plugins/sqldrivers/./../../lib/libQt6Sql.so.6 (0x00007f98c070b000) libQt6Core.so.6 => /opt/qt6.4/6.4.1/gcc_64/plugins/sqldrivers/./../../lib/libQt6Core.so.6 (0x00007f98c008d000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f98c006b000) libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f98bfe9e000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f98bfd5a000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f98bfd3e000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f98bfb69000) libicui18n.so.56 => /opt/qt6.4/6.4.1/gcc_64/plugins/sqldrivers/./../../lib/libicui18n.so.56 (0x00007f98bf6d0000) libicuuc.so.56 => /opt/qt6.4/6.4.1/gcc_64/plugins/sqldrivers/./../../lib/libicuuc.so.56 (0x00007f98bf318000) libicudata.so.56 => /opt/qt6.4/6.4.1/gcc_64/plugins/sqldrivers/./../../lib/libicudata.so.56 (0x00007f98bd935000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f98bd92f000) libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f98bd7fe000) libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f98bd7e1000) libgthread-2.0.so.0 => /lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007f98bd7dc000) librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f98bd7d2000) /lib64/ld-linux-x86-64.so.2 (0x00007f98c07b9000) libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f98bd75f000)
I sent my duck off and found the hint to copy the library.
So I issued a:
sudo ln -s libmariadb.so libmysqlclient.so.21
... but it turned out, that Qt does an internal check for the mysql version, which is not provided by any mariadb library ...
... so this driver could never work with a mariadb installation.
-
Hi,
I happen to note the same problem at linux debian system, using Qt6.4 from Qts binary installer.
I did some research and think, that the driver is not ready for mariadb usage.
my error messages are these:
qt.core.plugin.factoryloader: checking directory path "/opt/qt6.4/6.4.1/gcc_64/plugins/sqldrivers" ... qt.core.plugin.factoryloader: looking at "/opt/qt6.4/6.4.1/gcc_64/plugins/sqldrivers/qsqlpsql.debug" qt.core.plugin.factoryloader: "The shared library was not found." not a plugin qt.core.plugin.factoryloader: looking at "/opt/qt6.4/6.4.1/gcc_64/plugins/sqldrivers/qsqlmysql.debug" qt.core.plugin.factoryloader: "The shared library was not found." not a plugin qt.core.plugin.factoryloader: looking at "/opt/qt6.4/6.4.1/gcc_64/plugins/sqldrivers/libqsqlmysql.so" qt.core.plugin.loader: Found metadata in lib /opt/qt6.4/6.4.1/gcc_64/plugins/sqldrivers/libqsqlmysql.so, metadata= { "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface", "MetaData": { "Keys": [ "QMYSQL", "QMARIADB" ] }, "archlevel": 1, "className": "QMYSQLDriverPlugin", "debug": false, "version": 394240 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QMYSQL", "QMARIADB")
but when I look at the cited directory, it contains the named lib:
ls -l /opt/qt6.4/6.4.1/gcc_64/plugins/sqldrivers insgesamt 16260 -rwxr-xr-x 1 user user 1401600 8. Nov 11:51 libqsqlite.so -rwxr-xr-x 1 user user 94856 8. Nov 11:51 libqsqlmysql.so -rwxr-xr-x 1 user user 110760 8. Nov 11:51 libqsqlodbc.so -rwxr-xr-x 1 user user 102920 8. Nov 11:51 libqsqlpsql.so -rw-r--r-- 1 user user 9432120 8. Nov 11:48 qsqlite.debug -rw-r--r-- 1 user user 1739456 8. Nov 11:48 qsqlmysql.debug -rw-r--r-- 1 user user 1801824 8. Nov 11:48 qsqlodbc.debug -rw-r--r-- 1 user user 1947656 8. Nov 11:48 qsqlpsql.debug
so I checked dependencies of mysql library:
/opt/qt6.4/6.4.1/gcc_64/plugins/sqldrivers$ ldd libqsqlmysql.so linux-vdso.so.1 (0x00007ffcfcbdd000) libmysqlclient.so.21 => not found libQt6Sql.so.6 => /opt/qt6.4/6.4.1/gcc_64/plugins/sqldrivers/./../../lib/libQt6Sql.so.6 (0x00007f98c070b000) libQt6Core.so.6 => /opt/qt6.4/6.4.1/gcc_64/plugins/sqldrivers/./../../lib/libQt6Core.so.6 (0x00007f98c008d000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f98c006b000) libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f98bfe9e000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f98bfd5a000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f98bfd3e000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f98bfb69000) libicui18n.so.56 => /opt/qt6.4/6.4.1/gcc_64/plugins/sqldrivers/./../../lib/libicui18n.so.56 (0x00007f98bf6d0000) libicuuc.so.56 => /opt/qt6.4/6.4.1/gcc_64/plugins/sqldrivers/./../../lib/libicuuc.so.56 (0x00007f98bf318000) libicudata.so.56 => /opt/qt6.4/6.4.1/gcc_64/plugins/sqldrivers/./../../lib/libicudata.so.56 (0x00007f98bd935000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f98bd92f000) libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f98bd7fe000) libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f98bd7e1000) libgthread-2.0.so.0 => /lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007f98bd7dc000) librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f98bd7d2000) /lib64/ld-linux-x86-64.so.2 (0x00007f98c07b9000) libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f98bd75f000)
I sent my duck off and found the hint to copy the library.
So I issued a:
sudo ln -s libmariadb.so libmysqlclient.so.21
... but it turned out, that Qt does an internal check for the mysql version, which is not provided by any mariadb library ...
... so this driver could never work with a mariadb installation.
@django-Reinhard said in Problem loading MYSQL/MariaDB Driver in Manjaro Sikaris 22.0:
... but it turned out, that Qt does an internal check for the mysql version, which is not provided by any mariadb library ...
???
Please clarify. You have to use the correct library which you built the plugin against.
-
wrote on 7 Jan 2023, 09:43 last edited by
Hi Christian,
when you look at the first sentence of my posting - I was talking about binary distribution.
As Qt recommends binary installation by using their online installer, I would expect, that a binary installation should work ootb - but with respect to mariadb this is not true. And probably never has been.
I claim that mariadb has never been tested on a binary installation.
Sure - there's no problem, if you compile the driver on your own. But you shouldn't have to do it at all.
... any way - these commands lead to a working driver for mariadb - well, on my system (debian bullseye) with my qt installation. Build-directory may be created anywhere. Does not matter.
mkdir build-sqldrivers cd build-sqldrivers /opt/qt6.4/Tools/CMake/bin/cmake -G Ninja /opt/qt6.4/6.4.1/Src/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=/opt/qt6.4/6.4.1/gcc_64 -DMySQL_INCLUDE_DIR="/usr/include/mariadb" -DMySQL_LIBRARY="/usr/lib/x86_64-linux-gnu/libmariadbclient.so" cmake --build . cmake --install .
-
Hi Christian,
when you look at the first sentence of my posting - I was talking about binary distribution.
As Qt recommends binary installation by using their online installer, I would expect, that a binary installation should work ootb - but with respect to mariadb this is not true. And probably never has been.
I claim that mariadb has never been tested on a binary installation.
Sure - there's no problem, if you compile the driver on your own. But you shouldn't have to do it at all.
... any way - these commands lead to a working driver for mariadb - well, on my system (debian bullseye) with my qt installation. Build-directory may be created anywhere. Does not matter.
mkdir build-sqldrivers cd build-sqldrivers /opt/qt6.4/Tools/CMake/bin/cmake -G Ninja /opt/qt6.4/6.4.1/Src/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=/opt/qt6.4/6.4.1/gcc_64 -DMySQL_INCLUDE_DIR="/usr/include/mariadb" -DMySQL_LIBRARY="/usr/lib/x86_64-linux-gnu/libmariadbclient.so" cmake --build . cmake --install .
@django-Reinhard said in Problem loading MYSQL/MariaDB Driver in Manjaro Sikaris 22.0:
As Qt recommends binary installation by using their online installer, I would expect, that a binary installation should work ootb - but with respect to mariadb this is not true
Because the plugins was linked against the mysql libs, not the mariadb ones I would guess - and as I said above you have to use the same libs as the ones used during compilation since those two libraries are (nearly) source compatible but not binary compatible. Even if you would use a mysql library version x it may not work when the source was compiled and linked against version y.
-
Hi Christian,
when you look at the first sentence of my posting - I was talking about binary distribution.
As Qt recommends binary installation by using their online installer, I would expect, that a binary installation should work ootb - but with respect to mariadb this is not true. And probably never has been.
I claim that mariadb has never been tested on a binary installation.
Sure - there's no problem, if you compile the driver on your own. But you shouldn't have to do it at all.
... any way - these commands lead to a working driver for mariadb - well, on my system (debian bullseye) with my qt installation. Build-directory may be created anywhere. Does not matter.
mkdir build-sqldrivers cd build-sqldrivers /opt/qt6.4/Tools/CMake/bin/cmake -G Ninja /opt/qt6.4/6.4.1/Src/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=/opt/qt6.4/6.4.1/gcc_64 -DMySQL_INCLUDE_DIR="/usr/include/mariadb" -DMySQL_LIBRARY="/usr/lib/x86_64-linux-gnu/libmariadbclient.so" cmake --build . cmake --install .
wrote on 8 Jan 2023, 05:06 last edited byThis post is deleted! -
wrote on 8 Jan 2023, 06:27 last edited by
Well, I just found how to solve this.
As stated in the output I posted above, the problem it's basically Qt being unable to find libqsqlmysql.so, but thanks to ChatGPT and google searches I found a workaround:- Make sure that you have installed the MySQL client library on your system. You can check if it is installed by running the command locate libmysqlclient.so.21 (in case you are using Linux).
- Make sure that the MySQL driver library is in a location where your Qt application can find it. You can try adding the directory where the MySQL driver library is located to the LD_LIBRARY_PATH environment variable, by running the command: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/mysql/lib
- Then, run Qt from terminal. For example, I do it with this command: ~/Qt/Tools/QtCreator/bin/qtcreator
Thats it, now it should work.
If you don't want to execute the export LD_LIBRARY_PATH=... command everytime before opening Qt, you can set LD_LIBRARY_PATH under environment (Where you add environment variables) . Example:
After your default values in LD_LIBRARY_PATH, add ::/path/to/mysql/lib. If you do this, It's not necessary to open Qt from terminal anymore.
1/7