Skip to content
  • 0 Votes
    5 Posts
    168 Views
    D

    @Christian-Ehrlicher I solved the problem. After digging deeper, I found that in the function QMYSQLResult::reset(const QString& query) in the source code qsql_mysql.cpp, the field type of all data was set to the default value MYSQL_TYPE_DECIMAL(0). Also, I saw that it was loading another libmariadb.dll from the list of loaded dlls, which I had not specified. Eventually, I decided to start over, and after deleting Qt, MariaDB, MariaDB connector, and environment variables, rebuilding, installing, and building the plugin, it finally worked fine. I still don't know exactly what the problem was, but thank you for your attention.

  • 0 Votes
    69 Posts
    7k Views
    T

    @cpplegend maybe it gets us further if you post your project here first, incl CMakeLists.txt

  • 0 Votes
    17 Posts
    2k Views
    JonBJ

    @MH24
    It vaguely, vaguely rings a bell that you have to do something special about root, possibly to do with how MySQL gets installed initially. Lots of hits for Googling mysql root localhost permission. I may have done the stuff mentioned in https://stackoverflow.com/a/46908573 in the past. (Be careful you don't lock yourself out, however!)

    But in any case what you have done now is better, as @Christian-Ehrlicher said you should not be using root user for your application.

  • Building QMYSQL / MARIADB with Qt 6.3.0

    Unsolved Qt 6
    13
    0 Votes
    13 Posts
    2k Views
    SGaistS

    From memory, no, MariaDB is a drop in replacement so it would not make sense to complicate the build system for that.

  • 0 Votes
    2 Posts
    357 Views
    jsulmJ

    @Persivan said in QMYSQL driver not found after release:

    Any ideas?

    Yes, use search function in this forum - this is asked so often.
    Most probably the MySQL driver lib is missing.

  • 0 Votes
    44 Posts
    7k Views
    M

    @SGaist Hello! I'm building a second app using QMySQL database, the first app (the one about this topic) works perfectly as expected, but the second tells me that the driver isn't loaded.

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

    I added mysql dll dir in PATH environment variable, but same problem stay the same..

    Have you an idea please?

    EDIT: nevermind, I'm just stupid, I forgot the "Q" before "MYSQL" call in code line:

    QSqlDatabase db = QSqlDatabase::addDatabase("MYSQL");

    Now it's:

    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");

    and strangely, works better..

    Again, thank you all for your help!

  • 0 Votes
    26 Posts
    4k Views
    J

    Finally (!...) I was able to fix the problems. I'm showing the whole procedure, not only what relates to the main subject of this thread so that to contribute to the community..

    I was using the following sites as a source information to work out the following solution: LINK1 (for other Qt/Raspberry PI configuration check: link), LINK2, LINK3, LINK4, LINK5, LINK6.

    My hardware/software:

    Host:
    Ubuntu 18.04 (also I’ve check it on Ubuntu 20.04 and it also works)
    Qt ver. 5.12.3 (I also tried 5.12.9, but it didn’t work, probably there was something wrong with the fix that needs to be done on the sources) - you can install the “sources” and all the modules you need from Qt Online Installer (link) because later on you can add/remove modules/versions easily by lauching ~/Qt/MaintenanceTool
    QtCreator will be installed automatically (the newest version) when you use Qt Online Installer

    Target:
    Raspberry PI 3, with Raspbian Stretch

    Procedure:

    [on RPi] Edit sources list in /etc/apt/sources.list and uncomment the deb-src line: sudo nano /etc/apt/sources.list [on RPi] Update your system and install required libraries: sudo apt-get update sudo apt-get build-dep qt4-x11 sudo apt-get build-dep libqt5gui5 sudo apt-get install libudev-dev libinput-dev libts-dev libxcb-xinerama0-dev libxcb-xinerama0

    After installing MySQL itself on RPi install also MySQL libraries/packages to be used by Qt:

    sudo apt install mariadb-client libmariadb-dev-compat libqt5sql5-mysql [on RPi] Prepare our target directory sudo mkdir /usr/local/qt5pi sudo chown pi:pi /usr/local/qt5pi [on RPi] Correct links to EGL and GLES Drivers sudo rm /usr/lib/arm-linux-gnueabihf/libEGL.so.1.0.0 sudo rm /usr/lib/arm-linux-gnueabihf/libGLESv2.so.2.0.0 sudo ln -s /opt/vc/lib/libbrcmEGL.so /usr/lib/arm-linux-gnueabihf/libEGL.so.1.0.0 sudo ln -s /opt/vc/lib/libbrcmGLESv2.so /usr/lib/arm-linux-gnueabihf/libGLESv2.so.2.0.0 [on host] Create our working directory and get a toolchain: mkdir ~/raspi cd ~/raspi git clone https://github.com/raspberrypi/tools [on host] Create a sysroot. mkdir sysroot sysroot/usr sysroot/opt rsync -avz pi@yourpi:/lib sysroot rsync -avz pi@yourpi:/usr/include sysroot/usr rsync -avz pi@yourpi:/usr/lib sysroot/usr rsync -avz pi@yourpi:/opt/vc sysroot/opt [on host] Adjust symlinks to be relative: wget https://raw.githubusercontent.com/riscv/riscv-poky/master/scripts/sysroot-relativelinks.py chmod +x sysroot-relativelinks.py ./sysroot-relativelinks.py sysroot [on host] Modify the qmake.conf –> mkspecs/devices/linux-rasp-pi3-g++/qmake.conf nano ~/raspi/qtbase/mkspecs/devices/linux-rasp-pi3-g++/qmake.conf

    VC_LIBRARY_PATH = $$[QT_SYSROOT]/opt/vc/lib
    VC_INCLUDE_PATH = $$[QT_SYSROOT]/opt/vc/include

    VC_LINK_LINE = -L$${VC_LIBRARY_PATH}

    QMAKE_LIBDIR_OPENGL_ES2 = $${VC_LIBRARY_PATH}
    QMAKE_LIBDIR_EGL = $$QMAKE_LIBDIR_OPENGL_ES2
    QMAKE_LIBDIR_OPENVG = $$QMAKE_LIBDIR_OPENGL_ES2

    [on host] Protect your “sources” by creating working folder: cd ~/Qt/5.12.3 tar jcvf qt-5.12.3-src.tar.bz2 Src cd ~/raspi tar xvf ~/Qt/5.12.3/qt-5.12.3-src.tar.bz2 mv Src qt-5.12.3-src

    You can remove from qt-5.12.3-src the modules that you don’t want (at least for now) leaving qtbase folder - this will shorten the building process.
    Create also working folder for the building (if building would be unsuccessful all you need to do is to delete the content of this folder and start again):

    mkdir ~/raspi/build_raspi cd ~/raspi/build_raspi [on host] Configure
    From ~/raspi/build_raspi ../qt-5.12.3-src/configure -release -opengl es2 -device linux-rasp-pi3-g++ -device-option CROSS_COMPILE=~/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf- -sysroot ~/raspi/sysroot -opensource -confirm-license -make libs -prefix /usr/local/qt5pi -extprefix ~/raspi/qt5pi -hostprefix ~/raspi/qt5 -no-use-gold-linker -v -no-gbm -sql-mysql MYSQL_INCDIR=~/raspi/sysroot/usr/include/mysql MYSQL_LIBDIR=~/raspi/sysroot/usr/lib/arm-linux-gnueabihf

    Notice the above contains also building MySQL driver.

    Notice that the Config summary should contain (if it doesn't, you need to correct something... and do the configure again):
    EGLFS Raspberry Pi ................... yes
    MySql .................................. yes

    Regarding “-release” parameter read here (in other words you don’t need “-debug-and-release” and the warnings you can ignore… at least this is what I can read at the forum).

    [on host] Make
    From ~/raspi/build_raspi make

    You can use make -j 8 instead (much faster), but if there will be problems the all the “jobs” would need to finish and consequently it could be more difficult to find the error messages.

    [on host] Make install
    From ~/raspi/build_raspi: make install [on host] Deploy Qt to the device. We simply sync everything from ~/raspi/qt5pi to the prefix we configured above
    From ~/raspi: rsync -avz qt5pi pi@192.168.1.100:/usr/local [on host] Configuration of QtCreator: Tools > Options > Devices > Add > Generic Linux Device > Start Wizard Write: “Raspberry” (your custom name), “192.168.X.X” (your Raspberry PI address), “pi” (your Raspberry PI user) Don’t write anything at “private key”, click “Next” There will be error window with: “Device test failed” > Cancel Authentication type → choose: “Default” Now test connection (“Test” button) and after you give the password to the RPi it should be successful Kits > Compilers > Add > GCC > C Write: “GCC (Raspberry Pi)” as your custom name and: “~/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-gcc” as the path to the compiler Kits > Compilers > Add > GCC > C++ Write: “G++ (Raspberry Pi)” as your custom name and: “~/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-g++” as your path to the compiler Regarding the debugger, you should install:
    [On Host]: sudo apt-get install gdb-multiarch

    I’m not sure if this is needed but you can also install on RPi:

    sudo apt-get install gdbserver Kits > Debuggers > Add Write: “GDB (Raspberry Pi)” as your custom name and “/usr/bin/gdb-multiarch” as the path to the debugger Apply Kits > Qt Version > Add Write path: ~/raspi/qt5/bin/qmake Write name: Qt %{Qt:Version} (qt5) Raspberry PI Apply Kits > Kits > Add Name: Raspi Device Type: Generic Linux Device The Device is the one created in the previous step We set the Sysroot to where we have the sysroot image: ~/raspi/sysroot Set compilers: "GCC (Raspberry PI)" and "G++ (Raspberry PI)" Set the Debugger to the one created previously Use the Qt version we created previously We don't need to set mkspec, so leave it empty. OK To enable your running application to have regular window do the following:
    Projects > Raspberry PI > Run > Environment > Batch Edit: DISPLAY=:0.0 QT_QPA_PLATFORMTHEME=qt5ct XAUTHORITY=/home/pi/.Xauthority XDG_SESSION_TYPE=x11

    If you don’t do this your application after starting up will be shown full screen but you will see it only when directly connect a screen to Raspberry PI (VNC desktop sharing will show nothing)
    14) [on host] In your Raspberry PI project, in .pro file, you need to show where the executable file should be placed: (LINK):

    target.path = /home/pi INSTALLS += target

    So comment the previous settings, eg.:

    # qnx: target.path = /tmp/$${TARGET}/bin # else: unix:!android: target.path = /opt/$${TARGET}/bin # !isEmpty(target.path): INSTALLS += target [on host] If you get: “WARNING: The code model could not parse a included file, which might lead to incorrect code completion and highlighting”:
    You need to deselect “ClangCodeModel” in HELP > ABOUT PLUGINS and restart QtCreator (LINK). You should be able to build/run/debug your project on RPi and connect to the MySQL database without "QMYSQL driver not loaded" error.
  • 0 Votes
    6 Posts
    1k Views
    U

    @JKSH thanks

  • 0 Votes
    11 Posts
    2k Views
    Christian EhrlicherC

    See for example https://forum.qt.io/topic/107997/qt-win10-qmysql-driver-not-loaded or use the forum search function

  • 0 Votes
    6 Posts
    1k Views
    IMAN4KI

    Seems to be a bug reported here QTBUG-50244

    Nobody tried to integrate MySQL for a Raspberry Pi project already ?! no workaround?!
    Seems strange :(

  • 0 Votes
    8 Posts
    862 Views
    SGaistS

    Are you trying to move things around in the folder where you are currently doing the application deployment ?

  • 0 Votes
    6 Posts
    1k Views
    jsulmJ

    @Double-A said in QMYSQL Driver not loaded in Ubuntu:

    libmysqlclient.so.18

    As the error says it can't find libmysqlclient.so.18
    Also don't forget that on UNIX/Linux it is not enough to put the lib in same directory like on Windows.

  • 0 Votes
    14 Posts
    11k Views
    SGaistS

    You can't mix architectures. While there should be no problem connecting to a 64bit running server with a 32bit client. Loading the 64bit libraries with a 32bit plugin will not work.

  • 0 Votes
    9 Posts
    11k Views
    SGaistS

    Glad you found out and thanks for sharing your findings.

    Since you have it working now, please mark the thread as solved using the "Topic Tool" button so other forum users may know a solution has been found :)

  • 0 Votes
    28 Posts
    26k Views
    SGaistS

    @Gualtix Hi and welcome to devnet, you are not following the current documented procedure.

  • 0 Votes
    5 Posts
    5k Views
    SGaistS

    Way better !

    By the way, no need to modify the thread title anymore, just use the "Topic Tool" button to mark the thread as solved :)

  • 0 Votes
    16 Posts
    7k Views
    H

    @SGaist said:

    You are missing the openssl libraries

    It's not related to my issue because it points to "libqsqlmysql.so" which is not needed in my application (the needed one is libqsqlmysql.so)

    Any way, I fixed the problem (thanks to Hamish Moffatt from Qt mailing list) by removing "libqsqlmysql.so" (the old plugin original file shipped by Qt Installer) outside sqldrivers folder

  • 5 Votes
    32 Posts
    41k Views
    A

    im using qt 5.9 on mac this piece of code worked like charm for me

    brew install mysql-connector-c
  • 0 Votes
    6 Posts
    5k Views
    SGaistS

    Re-building the plugin to use your currently installed libmysqlclient_r would be the simple and easy path. Just grab the sources and follow the instruction in the database part of Qt's documentation.

  • 0 Votes
    5 Posts
    2k Views
    L

    It's been some time now. I don't remember exactly, but I think it was most likely from here:

    ftp://linorg.usp.br/mysql/Downloads/Connector-C/mysql-connector-c-6.1.5-src.zip

    It's one of the official mirrors.