1. 程式人生 > >Ubuntu16.04 QT "QMYSQL driver not loaded on Ubuntu"問題

Ubuntu16.04 QT "QMYSQL driver not loaded on Ubuntu"問題

原文:

Assuming that for getting this error you installed Qt from the binary packages downloaded from qt.io:

  • Install the MySQL client dev packages
  • Run the MaintenanceTool (somewhere where you installed Qt)
  • Ask it to install extra packages
  • Install the "Source Components" for at least the Essential modules
  • Go to /dir/where/you/installed/Qt/version/Source/
  • Go into qtbase/src/plugins/sqldrivers/mysql
  • Run qmake from the very same Qt version (/dir/where/you/installed/Qt/version/arch/bin/qmake or similar)
  • Run make, if it explodes with headers/libraries not found check that you installed those MySQL client dev packages correctly

That should give you a brand new plugin, and with fingers crossed, it's already put in the right place. Otherwise find the new libqsqlmysql.soldd it to be sure it was OK, and overwrite the old plugin with the new one.


翻譯一下:

1. 安裝 MySQL client dev 這個包可以通過 

sudo apt-get install libmysqlclient-dev
安裝。

2. 安裝QT,安裝的時候選擇元件選擇所有元件,如果已經安裝完成,可以使用安裝目錄下的 "MaintenanceTool" 檔案來新增元件,不過這個離線版的安裝包好像有BUG,不能新增,最後我刪除重灌QT。。。

3.  切換至  [QT安裝目錄]/[version]/Src/qtbase/src/plugins/sqldrivers/mysql 目錄下

4. 執行qmake命令,編譯mysql.pro 即

qmake mysql.pro
如果qmake沒有新增到環境變數,則使用qmake的完整路徑( [QT安裝目錄]/[version]/gcc_64/bin/qmake)。

5. 執行make,執行成功的最後一行應該是"mv  -f  libqsqlmysql.so ../../../../plugins/sqldrivers/"

6. 到上面那個目錄下找到 libqsqlmysql.so 檔案拷貝到 [QT安裝目錄]/[version]/gcc_64/plugins/sqldrivers下覆蓋舊的檔案。