Compile driver mysql to qt5 for Gnu/Linux ubuntu, debian and derivatives

Step 1: download qt5 y configure environment variables

Online installer: https://www.qt.io/download-qt-installer?hsCtaTracking=9f6a2170-a938-42df-a8e2-a9f0b1d6cdce%7C6cb0de4f-9bb5-4778-ab02-bfb62735f3e5

Offline installer: https://www.qt.io/offline-installers

Archive src, modules, offline: https://download.qt.io/archive/

Install the version of qt5 you want once installed, put this the .bashrc

export PATH="/home/"$USER"/Qt5.12.2/5.12.2/gcc_64/bin/":$PATH export LD_LIBRARY_PATH="/home/"$USER"/Qt5.12.2/5.12.2/gcc_64/lib/":$LD_LIBRARY_PATH export LD_LIBRARY_PATH="/home/"$USER"/Qt5.12.2/5.12.2/gcc_64/plugins/":$LD_LIBRARY_PATH export LIBRARY_PATH="/home/"$USER"/Qt5.12.2/5.12.2/gcc_64/lib/":$LIBRARY_PATH export LIBRARY_PATH="/home/"$USER"/Qt5.12.2/5.12.2/gcc_64/plugins/":$LIBRARY_PATH

It should look like this

select the version of qt you want to compile, in this case I am using version 5.12

now you can restart or simply in terminal place source .bashrc

Step 2: Download mysql-dev

apt-get install libmysqlclient20 libmysqlclient-dev libssl-dev

note: this can change according to the distribution you use libmysqlclient20 since this version is 20 you just have to search with apt-cache

Step 3: compile driver mysql QT5

Open terminal and execute commads

 mysql="/home/"$USER"/Qt5.12.2/5.12.2/Src/qtbase/src/plugins/sqldrivers/mysql"
 cd $mysql
 sed -i -e "s|QMAKE_USE += mysql|# QMAKE_USE += mysql|" mysql.pro
 ls

note: some versions of qt5 work with qmake qmake «INCLUDEPATH+=/usr/include/mysql» «LIBS+=-L/usr/lib/x86_64-linux-gnu/libmysqlclient.a -lmysqlclient_r» mysql.pro, you can see the discussion at https://stackoverflow.com/questions/4486584/what-is-difference-between-libmysqlclient-a-and-libmysqlclient-r-a

  • run qmake: qmake «INCLUDEPATH+=/usr/include/mysql» «LIBS+=-L/usr/lib/x86_64-linux-gnu/libmysqlclient.so -lmysqlclient» mysql.pro
  • Enter:
  • make
  • run and enter: make install
  • cd ../../../../../../gcc_64/plugins/sqldrivers/
  • ls

show driver mysql.

Esta entrada fue publicada en Uncategorized. Guarda el enlace permanente.