Qt uses msvc to compile the MySQL driver

Source: Internet
Author: User

After nearly one day of hard work, I finally completed MySQL driver compilation and used the msvc compiler. It was really troublesome. I found a lot of information on the Internet for mingw (this should be very simple, if you don't have enough energy, try again next week ). If you use msvc for compilation, you will not be able to succeed in the tutorial, and you will be able to reload all kinds of errors ...... I wrote out my problems and solutions today. I hope that my friends who encounter these problems will no longer have to submit their answers ......

I am using QT 4.8.1 and msvc2010. First download:

1. QT libraries 4.8.1 for Windows (V. S. 2010,235 MB)

2. Download MySQL and install it all (I use 5.5.22-Win32). Make sure the include and Lib folders are in the installation directory.

 

Start work:

1. Copy the include and Lib folders to a path without spaces. For example, I am in the root directory of drive D.

2. Copy Lib \ libmysql. DLL to the System32 folder to prevent errors.

3. Use a command prompt to enter the QT source file directory, for example, my: D: \ QT \ 4.8.1 \ SRC \ plugins \ sqldrivers \ mysql

4. run: qmake-O makefile export depath + = "D: \ include" libs + = "D: \ Lib \ libmysql. lib "MySQL. pro (includepath is the include file path of your MySQL, and libs is the directory of your Lib)

5. This is a response file generated in the Directory D: \ QT \ 4.8.1 \ SRC \ plugins \ sqldrivers \ mysql, as shown below:

 

6. Open command prompt in the QT source file directory in the Start Menu.

7. Run the nmake command

8. If the following error is prompted

 

Open the qsql_mysql.h file in D: \ QT \ 4.8.1 \ SRC \ SQL \ drivers \ mysql, modify row 52nd, and set

# Include <mysql. h> is changed to the directory where mysql. H is located. For example, on disk D, change it to # include <D: \ include \ mysql. h> and save it.

9. Continue nmake and continue with the error

 

Copy D: \ Lib \ libmysql. lib to the s2010 directory, such as D: \ Program Files \ Microsoft Visual Studio 10.0 \ Vc \ Lib

10. Continue to execute nmake. After successful execution, execute nmake release again. In this case, the D: \ QT \ 4.8.1 \ SRC \ plugins \ sqldrivers \ mysql \ release and debug directories are as follows:

 

There is a driver we need! Copy the following four files to D: \ QT \ 4.8.1 \ plugins \ sqldrivers.

 

Although it takes a long time for me to make a few simple steps, there will always be unexpected errors. Next time I will try mingw compilation.

 

 

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.