当前位置:网站首页>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 .
边栏推荐
- 字节跳动技术新人培训全记录:校招萌新成长指南
- SQL quick start
- Saw local status change event StatusChangeEvent [timestamp=1644048792587, current=DOWN, previous=UP]
- DS18B20数字温度计系统设计
- Jedis
- MP4格式详解
- 字节跳动技术面试官现身说法:我最想pick什么样的候选人
- Spark's RDD (elastic distributed data set) returns a large result set
- Continue and break jump out of multiple loops
- Shell_ 00_ First meeting shell
猜你喜欢
Chapter 7__ consumer_ offsets topic
Error occurred during initialization of VM Could not reserve enough space for object heap
【锟斤拷】的故事:谈谈汉字编码和常用字符集
LeetCode 1558. Get the minimum number of function calls of the target array
7-5 blessing arrived
Chapter 5 detailed explanation of consumer groups
was unable to send heartbeat
~Introduction to form 80
LeetCode 1560. The sector with the most passes on the circular track
字节跳动技术新人培训全记录:校招萌新成长指南
随机推荐
Gridhome, a static site generator that novices must know
Continue and break jump out of multiple loops
~72 horizontal and vertical alignment of text
~87 animation
How to configure hosts when setting up Eureka
Chapter 1 overview of MapReduce
~85 transition
Chapter 5 detailed explanation of consumer groups
Research Report on market supply and demand and strategy of China's four flat leadless (QFN) packaging industry
Educational Codeforces Round 122 (Rated for Div. 2)
Saw local status change event StatusChangeEvent [timestamp=1644048792587, current=DOWN, previous=UP]
第7章 __consumer_offsets topic
腾讯面试算法题
提交Spark应用的若干问题记录(sparklauncher with cluster deploy mode)
FLV格式详解
Li Kou leetcode 280 weekly match
Shell_ 04_ Shell script
The most lost road I have ever walked through is the brain circuit of ByteDance programmers
「博士毕业一年,我拿下 ACL Best Paper」
Native JS realizes the functions of all selection and inverse selection -- Feng Hao's blog