Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Qt4.8.6 compiling mysql driver-learn more

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

Qt4.8.6 compiling mysql driver-learn more

The blog post a few days ago described the case of connecting mysql database through Qt standard library SQL interface under the combination of Window+qt+vc++2017 compiler, and successfully solved the problem of failure to load mysql driver. Although there are some achievements, it still does not solve the problem of mysql database connection under the combination of Qt4.8.6+mingw.

1. Software environment

Operating system: windows10 (64 bit)

Qt version: 4.8.6 (mingw version)

Compiler: Gmail + (4.8.2)

MySQL:5.7.22 (64 bit, 32 bit,)

Gmail +-- the information queried by version is as follows:

G++.exe (i686-posix-dwarf-rev3, Built by MinGW-W64 project) 4.8.2

The information obtained by qmake-version is as follows:

QMake version 2.01a

Using Qt version 4.8.6 in C:\ Qt\ 4.8.6\ lib

2. Problems left over by history

1. There is no mysql driver by default in Qt4, so you need to compile manually.

2. To compile the mysql driver, you need to extract the include and lib in the mysql server program. Through web search, you can find that most solutions need to use the lib/opt directory, but this directory is no longer available in mysql5.7.

3. Compiling the mysql driver is completed by building the% QTDIR%\ src\ plugins\ sqldrivers\ mysql\ mysql.pro project. After the compilation is completed, the debug version and release version .a file and dll file are normally generated.

4. The history processing method is to modify the mysql.pro file and add two records (include and lib have been extracted):

INCLUDEPATH+= "C:\ driver2\ include"

LIBS+= "C:\ driver2\ lib\ libmysql.lib"

5. Through the above processing, a large number of "undefined reference to xxxxxx" errors will be reported in Qt Creator when building the project. At this point, it is impossible to continue.

6. Baidu N side, the solution is to repeat problem 4, almost in an endless cycle ().

3. N days later.

. @ ($* & (# @ * 7.

4. A stroke of genius

Occasionally clean up the junk file of the mysql.pro project, there is a qsqlmysl4.a file in the Debug directory, but there is no qsqlmysql4.dll file, you can confirm that the compilation is half successful, and part of your configuration is correct.

Rebuild the project, review the compiled output by self-study, and print "Makefile.Debug:77:recipe for target 'tdebug\ qsqlmysql4.dll' failed" on one line.

Baidu decisively took a look at this problem, and the final solution referred to the solution of the error in compiling the mysql driver by qt. The root cause of the problem is that the msyql installation is 64-bit, while the mingw version is 32-bit, resulting in a libmysql.dll file mismatch.

5. Thank you

Thank you all for your solution.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report