Compile the MySQL driver for QT in Ubuntu

Source: Internet
Author: User
The mysql driver is not added to QT, so you need to compile it yourself. We assume that you have installed mysql first, you must install mysql-devel, if not installed, it will appear that the problem of-lmysqlclient is not found, the Ubuntu name is libmysqlclient15-dev, so the sudoapt-getinstalllibmysqlclient15-dev next enters the QT to store the mysql driver source code directory, where $ QDIR for your installed QT

The mysql driver is not added to QT, so you need to compile it yourself.
Assume that you have installed mysql
First of all, you must install mysql-devel. If you do not install it, you will find the problem of-lmysqlclient, which is named libmysqlclient15-dev in Ubuntu, so

Sudo apt-get install libmysqlclient15-dev next enter the directory where QT stores mysql driver source code, where $ QDIR is the path to QT installed for you

Cd $ Q
TDIR/
Src/
Plugins/
Sqldrivers/
Mysql executes the qmake operation to generate makefile

Qmake "INCLUDEPATH + =/usr/include/mysql"
"LIBS + =-L/usr/lib/mysql-lmysqlclient_r"
Mysql.
Pro note that INCLUDEPATH is the path of your mysql. h file, and lib is the path of your mysql Library
Then execute make to generate libqsqlmysql. so

Make final execution

Make install to view the generated libqsqlmysql. so in $ QTDIR/plugins/sqldrivers /.
The installation is successful.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.