当前位置:网站首页>The QT program compiled on CentOS lacks a MySQL driven solution
The QT program compiled on CentOS lacks a MySQL driven solution
2022-07-06 16:53:00 【Flower dog fdog】
I used to write a communication from client to server , Has been windows Run above , Today, I want to hang the server on the ECS for testing , One mysql The driver made me all day , Looking for a lot of information , Finally, it was solved , Make a note of , I hope I can help the people behind .
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
Prompt unable to load driver
I think you should know it is libqsqlmysql.so The problem. , About compiling mysql Driven data , Each final solution focuses on libqsqlmysql.so This file .
If you are really the first material, click here , Then this article may help you solve the problem .
No matter what we need to download before , What to set , The ultimate essence is that we want to get libqsqlmysql.so This file
Witty, I went shopping csdn Resources for , I didn't expect that .
This is ready-made libqsqlmysql.so Documents , Just copy it directly .
Yes , The error that prompted that the database driver could not be loaded disappeared , But don't be happy , With it comes the following error
Cannot mix incompatible Qt library (version 0x50xxx) with this library (version 0x50xxx).
So I began to solve this mistake again , After some tossing , I gave up , I know this is an error caused by the wrong version , But it can't solve , I decided to put this libqsqlmysql.so Delete , Generate a unified version based on online information libqsqlmysql.so.
Download here libqsqlmysql.so There is no problem in itself , It's just a version problem , If you qt The version of is the same as that of the resource description , I think I can try .
Let's take a look at the serious compilation to generate this file .
The first situation on the Internet is , You haven't installed it yet qt, At this time , You install qt You can choose to install the source code , I think this method is the most ridiculous , I started to compile the program before the package made this mistake , You want me to reinstall qt Do you ~~~~
The second is from the qt Official download source code , I think this method is reliable .
This is the website http://download.qt.io/archive/qt/, Find and you qt The source code package corresponding to the version .
For example, I am a 5.1.0, Then click 

Then install a mysql Development kit
yum install mysql-devel
After downloading the source code , Remember to decompress , The order is as follows
tar -zxvf qt-everywhere-opensource-src-5.1.0.tar.gz
The unzipped folder and the compressed package are in the same place ,
It contains four original files 
All we have to do is compile this file , notice pro Suffixed files should be familiar .
How to compile , perform qmake
If qmake The environment variables have been configured , have access to qmake command , Yes pro File for compilation , If you are prompted qmake For invalid order , You can use the following path to compile , Still in this folder directory , Find you install qt The catalog of , Such as my /opt/Qt5.1.0/5.1/gcc_64/bin, In this directory you can find qmake, Use this path pair pro Compile .
The order is as follows :
/opt/Qt5.1.0/5.1/gcc_64/bin/qmake
After execution, it will generate Makefile file
And then execute make
If it works , You see in the last output line libqsqlmysql.so Where is the file , Such as :
If you are not familiar with this path , have access to pwd View path 
Another situation is make You don't succeed , Hint not found lmysqlclient_r
Use the find command
find /usr -name ‘*mysqlclient*’

You can see that there is this file , Just can't find , Let's make a soft connection
sudo ln -s /usr/lib64/mysql/libmysqlclient_r.so /usr/lib/libmysqlclient_r.so
We'll do it later make There is no problem .
In fact, you can see that this file also points to libmysqlclient.so Of 
And then find qt The corresponding path 
With newly generated libqsqlmysql.so Replace this qt Self contained libqslqmysql.so You can connect to the database normally .
边栏推荐
猜你喜欢

One hundred questions of image processing (1-10)

Eureka single machine construction
![Saw local status change event StatusChangeEvent [timestamp=1644048792587, current=DOWN, previous=UP]](/img/e6/c53ad67ead1793a2acb93c26e8d377.jpg)
Saw local status change event StatusChangeEvent [timestamp=1644048792587, current=DOWN, previous=UP]

Cmake Express

~76 sprite map

ByteDance open source Gan model compression framework, saving up to 97.8% of computing power - iccv 2021

LeetCode 1560. The sector with the most passes on the circular track

The concept of spark independent cluster worker and executor

Solr standalone installation

第三章 MapReduce框架原理
随机推荐
Spark独立集群Worker和Executor的概念
Introduction to microservices
Research Report on hearing health care equipment industry - market status analysis and development prospect prediction
字节跳动2022校招研发提前批宣讲会,同学们最关心的10个问题
~68 Icon Font introduction
JS encapsulates the method of array inversion -- Feng Hao's blog
LeetCode 1641. Count the number of Lexicographic vowel strings
~78 radial gradient
第7章 __consumer_offsets topic
string. How to choose h and string and CString
Solr word segmentation analysis
Research Report on market supply and demand and strategy of China's four seasons tent industry
[unsolved]7-14 calculation diagram
Use JQ to realize the reverse selection of all and no selection at all - Feng Hao's blog
Chapter 5 yarn resource scheduler
Native JS realizes the functions of all selection and inverse selection -- Feng Hao's blog
LeetCode 1984. Minimum difference in student scores
Cartesian tree (modified)
7-8 likes (need to continue to improve)
Submit several problem records of spark application (sparklauncher with cluster deploy mode)