Compile the MySQL driver of QT and its actual solution

Source: Internet
Author: User

This article mainly introduces the MySQL driver for compiling QT and its actual solution. If you encounter similar problems in actual operations, but you do not know how to solve them correctly, so the following articles must be good teachers and friends for you.

MySQL is used for graduation design. I want to use QT on the interface. By the way, I will learn how to use QT. I encountered a problem when I went up. The MySQL driver was actually found in the. \ Qt \ 4.6.0 \ plugins \ sqldrivers directory. After compilation, I found that I had to crash here ~). GOOGLE: after turning over the web page, we started to compile the MySQL driver.

Here we use the QT4.6.0 and VS2008 compiler.

The command line parameters used are:

Qmake-o Makefile export depath + = "D: \ Program Files \ MySQL Server 5.1 \ include" LIBS + = "D: \ Program Files \ MySQL Server 5.1 \ lib \ opt \ libMySQL. lib "MySQL. pro

Nmake

As expected, the compilation error is "cannot find file: MySQL. pro ", after a long time, I finally found that the directory I entered was ". \ Qt \ 4.6.0 \ src \ SQL \ drivers \ MySQL "instead of the legendary ". \ Qt \ 4.6.0 \ src \ plugins \ sqldrivers \ MySQL "directory is the correct path !). Comrades who have this error must check whether the command line path is correct!

After a problem is solved, qmake is successfully completed and nmake is started. The error "WinVer. h" cannot be found in qsqlMySQLd_resource.rc.

Find and find WinVer. the h header file is in the Windows SDK folder ". \ Microsoft Visual Studio 9.0 \ Common7 \ Tools "finds the batch processing of environment variables set by vsvars32.bat, drag the batch processing to the command line window and run it again. Note that this batch processing only sets the environment variables in the command line window and does not modify the registry, therefore, each time you open a new command line window, you must run a batch operation to obtain the environment variable settings contained in the batch operation !), Then nmake, the problem of WinVer. h cannot be found.

Again nmake, this time the problem is strange, and the "MySQL. h" cannot be found "! However, MySQL. h has already been included in the INCLUDEPATH parameter of qmake. How can I not find it?

Depressed. Open Makefile. debug check, and find that "D: \ Program Files \ MySQL Server 5.1 \ INCLUDE" is considered as a path at each space, qmake's IQ is too low! No way. Copy the include and lib folders in the MySQL Server 5.1 folder to the root directory. In this way, there is no space in the INCLUDEPATH and LIBS paths, and qmake, nmake, and OK again!

Summary: Considerations for compiling the MySQL driver using QT:

Check whether there is an SQL driver in ". \ Qt \ 4.6.0 \ plugins \ sqldrivers" first. If there is any, do not bother to compile it!

When installing MySQL, you must check the "C Include Files and Lib Files" option to install the MySQL header file and link library.

Do not have spaces in the path when installing MySQL. Otherwise, the compilation driver is too difficult to find the "MySQL. h" error ).

Before executing qmake and nmake on the command line, you must first transfer the "cannot find file: MySQL. pro" error to the correct directory )!

Run the vsvars32.bat batch before nmake and the "WinVer. h" error cannot be found ).

 

The above content is an introduction to the MySQL driver problem and solution for compiling QT. I hope you will get some benefits.

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.