当前位置:网站首页>General steps for QT compiling database plug-ins
General steps for QT compiling database plug-ins
2022-06-25 04:06:00 【feiyangqingyun】
I spent some time recently , On the basis of the previous database integration and application of this component, it is iterated and improved again , After ninety-one difficulties , take Qt Various database plug-ins , A dozen Qt edition , Compile it all , At the same time, the plug-in form of direct connection to the database and ODBC Data source connection mode , Have done various comparative tests , Different databases have different paging algorithms , Different date time range judgment query, etc .
Install the corresponding database , There will be include Header files and lib Link library files , This is the basic premise , To compile a database plug-in, you must have these two things . Be sure to pay attention to ,32 Bit Qt Must install 32 The database of bits can be compiled successfully , The number of digits should be consistent .
Prepare the database plug-in source code , such as qt-everywhere-src-5.14.2\qtbase\src\plugins\sqldrivers\mysql, Can be installed in Qt Check... When you're in src, Or you can download the source code and extract it from the official website in the later stage .
Open the source code of the database plug-in you want to compile , such as mysql Just turn it on mysql.pro,oracle Just turn it on oci.pro.
stay pro Comment out a line in #QMAKE_USE += mysql, If it is oci The project is #QMAKE_USE += oci.
qsqldriverbase.pri Note out in the document #include($$shadowed($$PWD)/qtsqldrivers-config.pri).
mysql.pro Add the following code below the contents of the file .
path = C:/Qt/mysql-5.7.30-winx64
INCLUDEPATH += $$path/include
win32:LIBS += -L$$path/lib -llibmysql
- oci.pro Add the following code below the contents of the file .
path = C:/app/Administrator/product/11.2.0/client_1
INCLUDEPATH += $$path/oci/include
win32:LIBS += -L$$path/oci/lib/msvc -loci
The above writing method also supports mingw and msvc, The compilation process of other systems is similar . After compilation, it will be in the root directory of the drive letter where your current source code is located by default , There will be plugins Catalog , Inside sqldrivers The directory is the corresponding compiled plug-in dynamic library .
Default oracle The plug-in driver code of is based on oracle12 Written by the function of , If the link is oracle11, You need to change two lines of code to compile successfully . open qsql_oci.cpp The document is probably in 1559 Line code around , There is one OCIBindByPos2 The function is changed to OCIBindByPos, There is another line below bindColumn.lengths Change to (ub2*)bindColumn.lengths.
Package and release the program , All premises : Pay attention to distinguish between 32/64 position , Your program is 32 You have to take it with you 32 Bit Library ,64 You must bring 64 Bit Library , this Qt This is also the requirement for the library .mysql Publishing is the easiest , Take one mysql The dynamic library file of (windows On is libmysql.dll), It's simple .sqlserver No need to bring it , Because he is the son of Microsoft , The general operating system comes with .postgres Need to bring libpq.dll、libintl-8.dll、libiconv-2.dll、libeay32.dll、ssleay32.dll Just a few files .oracle A special , There are a lot of documents , Basically, it is recommended to install one directly oracle client Client software , Then corresponding bin Just set the directory to the environment variable .
Test it after packaging and publishing , Find out 32 Bit programs can also be connected normally 64 Bit mysql,64 Bit programs can also be connected normally 32 Bit mysql, Therefore, the judgment is as long as it is consistent with the number of bits in the library of the program ( The same rule applies when compiling ,32 Bit Qt The program compilation database plug-in also needs to use 32 Bit database link library .), It does not need to be consistent with the number of digits in a specific database , tested mysql、sqlserver Databases are similar rules ,postgresql Only tested 32 position ,oracle Only tested 64 position , Now most systems are also 64 Yes. .
A lot of tests are compared , adopt odbc A large number of data records are inserted in batch by means of data source and direct database , Direct connection is faster , about 5% about , Therefore, it is recommended to adopt this method as far as possible , It is only in the environment without this method that odbc The way of data sources ,Qt The default always comes with odbc Database plug-ins .
边栏推荐
猜你喜欢
JSP cannot be resolved to a type error reporting solution
Smart wind power: operation and maintenance of digital twin 3D wind turbine intelligent equipment
zabbix的安装避坑指南
数学分析_笔记_第3章:极限
MySQL modifies and deletes tables in batches according to the table prefix
Crawler crawls Sina Weibo data
Development of trading system (VI) -- HFT high frequency trading
1. first knowledge of chromatic harmonica
Crawl Sina Weibo fans
Simple integration of client go gin -update
随机推荐
Hello CTP (II) -- Introduction to CTP
Development of trading system (VIII) -- Construction of low delay network
严重的PHP缺陷可导致QNAP NAS 设备遭RCE攻击
Smart wind power: operation and maintenance of digital twin 3D wind turbine intelligent equipment
@RequestBody解决获取参数为null
[harmony OS] [ark UI] basic ETS context operations
La gamme NFT Color, qui représente la diversité, est en ligne sur la plate - forme du marché Sandbox
Preparedstatement principle of preventing SQL injection
学习码 滚动码 固定码 有什么区别重码数,编码容量滚动码的原理
opencv是开源的吗?
Work assessment of pharmaceutical polymer materials of Jilin University in March of the 22nd spring -00025
教你如何在winpe里安装win11系统
《悉达多》:一生之书,可以时常反刍
Flutter Builder & FutureBuilder组件
numpy np tips:使用opencv对数组插值放缩到固定形状 cv2.resize(res, dsize=(64, 64), interpolation=cv2.INTER_CUBIC)
About PLSQL error initialization failure
DAP数据调度功能完善说明
Standing at the center of the storm: how to change the engine of Tencent
Exercise: how difficult is it to simulate the blessing lottery two-color ball - China 500W grand prize? Just run the code.
1.初识半音阶口琴