当前位置:网站首页>The difference between MFC for static libraries and MFC for shared libraries
The difference between MFC for static libraries and MFC for shared libraries
2022-07-01 03:37:00 【Three Belle Wenzi】
Daily use MFC When developing dynamic link libraries , You may face “MFC Use ” This option , There are three options in this option , Namely :
Use standards Windows library
Use... In a static library MFC
Sharing DLL Use in MFC
So what's the difference between the three ? Why set these three methods ?
According to the problems encountered in the development of the project , According to my own understanding, I will uncover the differences among the three .
We all know , What is a dynamic library , If you don't know, you can see what Xiaobian sorted out before Dynamic link library article , Dynamic link libraries usually do not run directly on the operating system , The suffix that he presents on our computer is .dll, At the same time, it cannot receive messages . It is a separate file , Only in one executable (windows On is .exe) To be called to take effect . as everyone knows ,Windows API All the functions in are contained in DLL in , Among them is 3 The most important DLL Namely :
Kernel32.dll: Contains for managing memory 、 Functions of processes and threads , for example CreateThread function ;
User32.dll: Contains tasks for performing user interface ( Such as window creation and message delivery ) Function of , for example CreateWindow function ;
GDI32.dll: Contains functions for drawing and displaying text .
When we are creating MFC During the project , Select create dynamic link library project , After compilation, an additional import and storage file will be generated under the file path of the generation library , The suffix of the import and storage file is also “lib”, For example Serven.lib file :

however , There is an essential difference between dynamic link library and static library , To a DLL Come on , The import and storage file contains the DLL Symbolic names of exported functions and variables , and DLL The file contains the DLL Actual functions and data . In the case of using dynamic libraries , When compiling linked executables , Just link to the DLL Import library file , The DLL The function code and data in are not copied to the executable , Until the executable runs , Take the... Required for loading DLL, Will be DLL Map to the address space of the process , And then visit DLL Functions exported in . At this time , When launching products , Out of the release executable , You also need to publish the dynamic link library that the program will call , As shown in the figure below , Suppose our executable program is Servenexe.exe,DLL The library file is Serven.dll, When publishing, package the two files into a folder and publish them together .

Said so much , Let's take a look “ Use shared dynamics MFC DLL The rules of (D)” and “ With static links MFC The rules of ”.
Use shared dynamics MFC DLL The rules of (D):

When the compiler compiles , Will not put MFC Library functions to compile in , That is to say , When we're in DLL The program uses MFC Library function ( for example CreateWindows()), The compiler won't compile this function in , So this requirement is to run this dll The file must have been installed on the computer MFC Library function , That is, installation MFC Environment . If it is not installed on the computer , Then the following error message will appear :

Hint you didn't , The program did not find the corresponding MFC Library function . The disadvantage of using this method is that it requires that the computer running the library must install the corresponding MFC Library function .
Use “ With static links MFC The rules of ” The way :

When the compiler compiles , Will be able to MFC Library functions to compile in , That is to say , When we're in DLL The program uses MFC Library function ( for example CreateWindows()), The compiler will compile this function , So this does not require running this dll The file must have been installed on the computer MFC Library function , That is, installation MFC Environment . But this one has a drawback is that it is compiled dll The size of will be larger than using shared dynamics .
summary :
Use standards Windows library : Can only be used in non MFC In Engineering , If in MFC The project will cause code compilation errors ;
Sharing DLL Use in MFC: The generated program executable file is relatively small , However, it is required that the necessary... Must be installed on the target machine MFC The library files ;
Use... In a static library MFC: The generated program executable files are almost all Windows Can be executed , But the memory occupied by this program after it is generated will be relatively large , Because the program contains the necessary MFC The library files , It can ensure normal operation on other machines .
边栏推荐
- 访问阿里云存储的图片URL实现在网页直接预览略缩图而不直接下载
- [deep learning] activation function (sigmoid, etc.), forward propagation, back propagation and gradient optimization; optimizer. zero_ grad(), loss. backward(), optimizer. Function and principle of st
- shell脚本使用两个横杠接收外部参数
- 【伸手党福利】开发人员重装系统顺序
- Pytorch training deep learning network settings CUDA specified GPU visible
- Leetcode:剑指 Offer 59 - I. 滑动窗口的最大值
- Listener listener
- 文件上传下载
- 多元线性回归
- 衡量两个向量相似度的方法:余弦相似度、pytorch 求余弦相似度:torch.nn.CosineSimilarity(dim=1, eps=1e-08)
猜你喜欢

衡量两个向量相似度的方法:余弦相似度、pytorch 求余弦相似度:torch.nn.CosineSimilarity(dim=1, eps=1e-08)

Pyramid Scene Parsing Network【PSPNet】论文阅读

File upload and download

The combination of applet container technology and IOT

FCN全卷积网络理解及代码实现(来自pytorch官方实现)

How do spark tasks of 10W workers run? (Distributed Computing)

LeetCode 128最长连续序列(哈希set)

TEC: Knowledge Graph Embedding with Triple Context

AfxMessageBox和MessageBox的用法

Leetcode 128 longest continuous sequence (hash set)
随机推荐
文件上传下载
Binary tree god level traversal: Morris traversal
C语言的sem_t变量类型
JUC学习
jeecgboot输出日志,@Slf4j的使用方法
E15 solution for cx5120 controlling Huichuan is620n servo error
[small sample segmentation] interpretation of the paper: prior guided feature enrichment network for fee shot segmentation
Appium自动化测试基础 — APPium基本原理
pytorch训练深度学习网络设置cuda指定的GPU可见
访问阿里云存储的图片URL实现在网页直接预览略缩图而不直接下载
Leetcode:829. Sum of continuous integers
AfxMessageBox和MessageBox的用法
pytorch nn. AdaptiveAvgPool2d(1)
Ridge regression and lasso regression
Valid brackets (force deduction 20)
Clion and C language
How do spark tasks of 10W workers run? (Distributed Computing)
ASGNet论文和代码解读2
IPv4和IPv6、局域网和广域网、网关、公网IP和私有IP、IP地址、子网掩码、网段、网络号、主机号、网络地址、主机地址以及ip段/数字-如192.168.0.1/24是什么意思?
Asgnet paper and code interpretation 2