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

相關文章
相關標籤/搜索