当前位置:网站首页>【Qt】添加第三方库的知识补充
【Qt】添加第三方库的知识补充
2022-07-01 02:51:00 【不知道在干嘛每天】
写在前面
本文将针对QT添加第三方库的过程和原理做一个知识的补充,包括静态库和动态库、MinGW和MSVC、make和makeinstall、debug和release、环境变量等。(C++中同理)
1、库
1.1、静态库
Windows :.lib
Linux\Mac:.a
静态库在编译的时候会被直接拷贝到目标程序里。
(程序打包后,放到没有环境的电脑中,也可以正常运行)
2.2、动态库
Windows :.dll
Linux:.so
Mac: dylib
动态库在编译时并不会被拷贝到目标程序中,只会在运行的时候调用。
(程序打包后,放到没有环境的电脑中,可能无法正常运行;需要把相应的dll
动态库一起打包才能正常运行)
2、编译器
2.1、MSVC
MSVC是指微软的VC编译器,主要用于windows下开发。
(使用msvc导入第三方库的时候,库文件一般是.lib
)
2.2 MinGW
MinGW是指是Minimalist GNU on Windows的缩写。它是一个可自由使用和自由发布的Windows特定头文件和使用GNU工具集导入库的集合,允许你 在GNU/Linux和Windows平台生成本地的Windows程序而不需要第三方运行时库。
(使用mingw导入第三方库的时候,库文件一般是.a
)
3、make和make install
3.1、make
make是用来编译的,它从Makefile中读取指令,然后编译。
如果你使用静态库,只需要make即可,生成.lib
或者.a
。
3.2、make insatll
make install是用来安装的,它也从Makefile中读取指令,安装到指定的位置。
如果你使用动态库,需要make insatll
,生成.dll
或者.so
。一般使用动态库在导入库之前需要配置环境变量。
4、配置环境变量
配置环境变量一般是可执行文件.exe
的目录。
如果配置第三方库、则是配置动态库的目录,一般在make insatll
之后生成的bin
目录中,里面包含dll
或.exe
文件
5、在windows调用静态库
(静态库只需编译,不用make insatll
)
一般先用cmake生成makefile,或者sln
5.1 MingGw
用mingw32-make
编译
获取编译好的.a
文件
在代码中配置.a
文件和头文件(include)
5.2 MSVC
打开camke生成的sln(用vs2019)
选择Debug或者Release,x86\x64
选择ALL_BUILD, 右击, 重新生成
获取输出的.lib
文件,区分debug和release
在代码中配置.lib
文件和头文件(include)
6、在windows调用动态库
(动态库需要make insatll
)
一般先用cmake生成makefile,或者sln
5.1 MingGw
用mingw32-make
编译
然后再mingw32-make install
在输出的目录中一般有一个bin
目录,里面有dll
或exe
将这个bin
目录的路径添加到环境变量
获取编译好的.a
文件(一般在lib
目录下)
在代码中配置.a
文件和头文件(include)
5.2 MSVC
待补充…
7、在VS2019中添加第三方库
一般动态库这样配置
静态库这样配置
边栏推荐
猜你喜欢
Saving images of different depths in opencv
Restcloud ETL data realizes incremental data synchronization through timestamp
Complete training and verification of a neural network based on pytorch
Densenet network paper learning notes
DenseNet网络论文学习笔记
Lenovo x86 server restart management controller (xclarity controller) or TSM method
CentOS installs multiple versions of PHP and switches
pycharm 软件deployment 灰色 无法点
UE4渲染管线学习笔记
RestCloud ETL实践之无标识位实现增量数据同步
随机推荐
How to buy Hong Kong shares in China? What platform is safer?
lavaweb【初识后续问题的解决】
Dell server restart Idrac method
Const and the secret of pointers
联想X86服务器重启管理控制器(XClarity Controller)或TSM的方法
Is it safe to open a stock account? Shanghai stock account opening procedures.
ANR问题的分析与解决思路
Voici le programme de formation des talents de SHARE Creators!
Pychar open remote directory remote host
鼠标悬停效果十
Mouse over effect V
STM32——一线协议之DS18B20温度采样
鼠标悬停效果六
Record a service deployment failure troubleshooting
Image preloading in JS
Résumé des styles de développement d'applets Wechat
Poj-3486-computers[dynamic planning]
I want to know how to open a stock account? Is it safe to open an account online?
Od modify DLL and exe pop-up contents [OllyDbg]
SSH configuration password free login error: /usr/bin/ssh copy ID: error: no identities found solution