MySQL driver for compiling Qt5 under Fedora17

Source: Internet
Author: User
Linux operating system: Fedora17 because MySQL belongs to Oracle, the Qt library does not contain the MySQL driver, but the source code provides the project file for compiling the MySQL driver, you need to use this project file to compile the MySQLl driver. Two prerequisites are required before Compilation: 1. install mysql-devel. This package contains the mysql header file and library 2. find the mysql driver compilation project file from the source code package Ps: Because Qt5.0

Linux: Fedora 17

Because MySQL belongs to Oracle, the Qt library does not contain the MySQL driver, but the source code provides the project file for compiling the MySQL driver. Therefore, you need to use this project file to compile the MySQLl driver. Two prerequisites are required before Compilation:

1. mysql-devel is installed. This package contains the header file and library of mysql.

2. Find the mysql driver compilation project file from the source code package.

Ps:

Because Qt5.0.0 is installed in SDK mode, the directory after installation does not contain the source code directory, that is, the src directory.

So we need to find from the folder extracted from the source code compressed package. Here I am, as long as the source code package downloaded from the official website is basically the same path

Qt-everywhere-opensource-src-5.0.0 \ qtbase \ src \ plugins \ sqldrivers \ mysql

Compilation steps:

1. Go to the mysql driver project directory in the source code package. My path is as follows:

Cd/home/alllen/qt-everywhere-opensource-src-5.0.0/qtbase/src/plugins/sqldrivers/mysql

2. Generate the makefile file

Add the mysql header file and library file to the project file to generate the makefile

Qmake "INCLUDEPATH + =/usr/include/mysql" "LIBS + =-L/usr/lib64/mysql-lmysqlclient_r" mysql. pro

Ps:

The mysql folder under include and lib64 must be included. Otherwise, the file will not be linked during compilation.

3. Start Compilation

Make directly

After compilation, it is generated in the qt-everywhere-opensource-src-5.0.0/qtbase/plugins/sqldrivers directory

Libqsqlmysql. so

This is done, and then copy the dynamic link library file to the location under your Qt installation directory:

/Home/alllen/Qt5.0.0/5.0.0/gcc_64/plugins/sqldrivers

Everything is OK.

For more information about Fedora, see Fedora topics page http://www.linuxidc.com/topicnews.aspx? Tid = 5

Related Article

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.