linux qt 5.12.6 編譯mysql驅動


環境:ubuntu 18.4 x64、qt 5.12.6

問題:安裝后是沒有mysql的驅動的

解決過程:

各種搜索,先后安裝了mysql mysql-client,mysql-server,和各種libdev之類的東西,好像和結果沒啥關系

隔了一天,繼續搜索,試了個法子,一次性成功了,是qt 官方論壇里的一個評論:

灰色字體的不用看了,介紹背景的,紅色字體是我加的說明

 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

  • #根據自己安裝的目錄調整實際路徑
  • #我的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 install

然后再去qt安裝目錄,/home/key/Qt/5.12.6/gcc_64/plugins/sqldrivers,已經生成了msyql的庫文件


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM