当前位置:网站首页>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 .
边栏推荐
- Chapter 6 datanode
- J'ai traversé le chemin le plus fou, le circuit cérébral d'un programmeur de saut d'octets
- MP4格式详解
- Research Report on market supply and demand and strategy of China's four seasons tent industry
- I'm "fixing movies" in ByteDance
- ~75 background
- string. How to choose h and string and CString
- LeetCode 1984. Minimum difference in student scores
- Research Report on hearing health care equipment industry - market status analysis and development prospect prediction
- How to generate six digit verification code
猜你喜欢
SQL quick start
Solr standalone installation
The 116 students spent three days reproducing the ByteDance internal real technology project
J'ai traversé le chemin le plus fou, le circuit cérébral d'un programmeur de saut d'octets
Ffmpeg command line use
图像处理一百题(1-10)
Spark独立集群Worker和Executor的概念
~85 transition
~86m rabbit practice
Simple records of business system migration from Oracle to opengauss database
随机推荐
Eureka single machine construction
~78 radial gradient
Basic principles of video compression coding and audio compression coding
LeetCode 1557. The minimum number of points that can reach all points
Spark's RDD (elastic distributed data set) returns a large result set
~69 other ways to use icon fonts
How to generate six digit verification code
LeetCode 1637. The widest vertical area between two points without any point
Shell_ 03_ environment variable
亮相Google I/O,字节跳动是这样应用Flutter的
谢邀,人在工区,刚交代码,在下字节跳动实习生
Codeforces Global Round 19
LeetCode 1566. Repeat the pattern with length m at least k times
7-4 harmonic average
LeetCode 1550. There are three consecutive arrays of odd numbers
Tencent interview algorithm question
ByteDance new programmer's growth secret: those glittering treasures mentors
@RestController、@Controller
Li Kou leetcode 280 weekly match
Spark独立集群动态上线下线Worker节点