linux qt 5.12.6 编译mysql驱动

环境:ubuntu 18.4 x6四、qt 5.12.6mysql

问题:安装后是没有mysql的驱动的linux

解决过程:android

各类搜索,前后安装了mysql mysql-client,mysql-server,和各类libdev之类的东西,好像和结果没啥关系web

隔了一天,继续搜索,试了个法子,一次性成功了,是qt 官方论坛里的一个评论:sql

灰色字体的不用看了,介绍背景的,红色字体是我加的说明ubuntu

 brochiha 2019年10月28日 下午11:22

These are the instruction that I made after installed it on my Ubuntu 18.04 linux install. Maybe it will help you
Download QT 5.12.4 from QT website using the downloads buttons and then select open source and download

After Download is complete go to Downloads folder and run the installer
(for new ubuntu users – right click on file in downloads and select permissions and select option at bottom)

Download latest QT that is known to have LTS (long term support)
-Run installer
-deselect android stuff and make sure that you select the dev tools and sources at the bottom
install QT

download and install mysql and dev packages

sudo apt-get install libglu1-mesa-dev
sudo apt-get install build-essential
sudo apt-get install libmysqlclient-dev
sudo apt-get install libssl-dev字体

注:上面这几句估计就是我昨天安装的那堆东西里都有的,今天没再执行;应该是必须的。

navigate to your Qt folder/5.12.4/Src
-run config file
./configure -plugin-sql-mysql

Navigate to qt source ie...Qt/5.12.4/Src/qtbase/src/plugins/sqldrivers/mysql
-run the QT qmake ui

  • #根据本身安装的目录调整实际路径
  • #个人qt装在了/home/Qt/5.12.6/gcc_64....
  • #MYSQL_PREFIX=后面是须要引用的mysql相关的头文件的路径,不知道的化,能够执行whereis mysql命令
  • #列出的路径里应该有include/mysql之类的,本身进去看看里面的内容就肯定是否是了;

/home/bj/Qt/5.12.4/gcc_64/bin/qmake MYSQL_PREFIX=/usr/include/mysql/ mysql.pro
locations may vary depending on where you installed Qt during the installation process and what version of Ubuntu you may be using
after running qmake
-run make
-make installspa

而后再去qt安装目录,/home/key/Qt/5.12.6/gcc_64/plugins/sqldrivers,已经生成了msyql的库文件server

相关文章
相关标签/搜索