Qt compiled MySQL database driver (MSVC)

Source: Internet
Author: User
Tags visual studio 2010

Qt compiled MySQL database driver (MSVC) (2013-12-13 20:24:46) reproduced
Tags: qt mysql qmysql qt compilation MySQL qt msvc compile MySQL Category: Qt
The QT Operations Database (SQLite) has been introduced to the question of how QT operates the database. Due to licensing restrictions, the open source version of QT does not provide all the drivers, and when you configure QT, you can choose the SQL driver that QT itself contains.
Note:Qt5.2 Previous version, the database provided includes: ODBC, SQLite, PSQL, others do not provide the need to compile themselves. However, starting with Qt5.2, MySQL is already included and does not need to be compiled manually. But in order to illustrate how to use MySQL, the usage of each version is compared and illustrated here. Qt5.2 versionInstall Qt5.2 version, can be viewed under the installation directory, pluins\sqldrivers, bread contains MySQL driver.
Previous versions of Qt5.2MySQL needs to compile itself for versions prior to 5.2, where 5.2 is the case (other versions are the same). For a database-driven introduction and how to compile, you can refer to the QT Helper, which has a section: SQL database Drivers.
  Here's how to compile MySQL with msvc. Environment: VS2010 + Qt5.2In fact, the version of the problem does not have much impact, because the compilation is quite similar ... Download QT installation package and QT Plugin
    • Qt-windows-opensource-5.2.0-msvc2010_opengl-x86-offline.exe
    • Qt-vs-addin-1.2.2-opensource.exe
Refer to: vs Integrated Qt Environment setup. Note:When installing OpenSource, remember to choose the source code, or compile the time you have to re-download. Second, download MySQL
    • MySQL homepage: http://www.mysql.com/.
(1) Go to the homepage, select: Downloads (GA) is as follows: (2) go to the bottom of the page, MySQL Community Edition (GPL), select: Download from MySQL Developer Zone >> As follows:

(3) Go to the upper right corner of the page, select: New releases corresponding version (here I choose 5.6) is as follows: (4) go to the bottom of the page, other Downloads, select the corresponding version (here I choose 32 bit) as follows: After the download is complete, unzip , copy to a specified path (I chose: D:\mysql-5.6.15-win32). Iii. compilation (1) Select: Start All Programs->qt5.2.0->qt5.2.0->msvc opengl->qt5.2.0 for Desktop (MSVC OpenGL) is as follows: (2) Enter Qt source Directory, my: D:\Software\Qt\Qt5.2.0\5.2.0\Src\qtbase\src\plugins\sqldrivers\mysql (3) Execute command: Qmake "includepath+=d:\    Mysql-5.6.15-win32\include "" Libs+=d:\mysql-5.6.15-win32\lib\libmysql.lib "Mysql.pro as follows: When execution is complete, a makefile file is generated. as follows: (4) Select: Start All Programs->microsoft Visual Studio 2010->visual Studio tools->visual Studio Command Prompt (2010) is as follows: (5) Execute command: NMAKE as follows:
After the normal end, the MySQL driver library will be generated. As follows:

(6) The preparation environment copies the generated Qsqlmysql.dll and Qsqlmysqld.dll to the D:\Software\Qt\Qt5.2.0\5.2.0\msvc2010_opengl\plugins\sqldrivers directory. Copy Libmysql.dll, libmysqld.dll from MySQL directory (D:\mysql-5.6.15-win32\lib) to D:\Software\Qt\Qt5.2.0\5.2.0\msvc2010_opengl     \ bin directory. All right, here we go.

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.