当前位置:网站首页>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 .
边栏推荐
- ~72 horizontal and vertical alignment of text
- string. How to choose h and string and CString
- Business system compatible database oracle/postgresql (opengauss) /mysql Trivia
- One hundred questions of image processing (1-10)
- Erlang installation
- 字节跳动2022校招研发提前批宣讲会,同学们最关心的10个问题
- ~87 animation
- Solr standalone installation
- LeetCode 1552. Magnetic force between two balls
- How to configure hosts when setting up Eureka
猜你喜欢

第三章 MapReduce框架原理

字节跳动新程序员成长秘诀:那些闪闪发光的宝藏mentor们

LeetCode 1552. Magnetic force between two balls

第6章 Rebalance详解

Mp4 format details

LeetCode 1557. The minimum number of points that can reach all points

Shell_ 03_ environment variable

Business system compatible database oracle/postgresql (opengauss) /mysql Trivia

LeetCode 1558. Get the minimum number of function calls of the target array

~85 transition
随机推荐
~73 other text styles
第一章 MapReduce概述
MP4格式详解
Redis standalone startup
LeetCode 1584. Minimum cost of connecting all points
SQL快速入门
LeetCode 1558. Get the minimum number of function calls of the target array
Gridhome, a static site generator that novices must know
~68 Icon Font introduction
Audio and video development interview questions
Ffmpeg command line use
ByteDance open source Gan model compression framework, saving up to 97.8% of computing power - iccv 2021
Erlang installation
~86m rabbit practice
How to generate six digit verification code
7-4 harmonic average
字节跳动多篇论文入选 CVPR 2021,精选干货都在这里了
Shell_ 03_ environment variable
LeetCode 1545. Find the k-th bit in the nth binary string
The concept of spark independent cluster worker and executor