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.