Qt uses msvc to compile MySQL driver _ MySQL

Source: Internet
Author: User
Qt uses msvc to compile the MySQL driver bitsCN.com

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, such as 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 follows:

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 Change to the directory where mysql. h is located. for example, change my disk to # include , And then save.

9. continue nmake and continue with the error

Copy D:/lib/libmysql. lib to the s2010 Directory, for example, 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 directory D:/Qt/4.8.1/src/plugins/sqldrivers/mysql/release and debug 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.

Author: Tianmu
Source: http://rophie.cnblogs.com/
The copyright of this article is shared by the author and the blog Park. You are welcome to repost this article. However, you must retain this statement without the author's consent and provide a clear link to the original article on the article page. Otherwise, you will be held legally liable.

-----------------------------------------------

Time splash dust, fly a little warm as smoke old dream, across my eyes.

BitsCN.com

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.