当前位置:网站首页>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 .
边栏推荐
- 后台系统右边内容如何出现滚动条和解决双滚动条的问题
- C#实现基于广度优先BFS求解无权图最短路径----完整程序展示
- Split(), split(), slice(), can't you tell?
- Include() of array
- Leetcode 31 next spread, leetcode 64 minimum path sum, leetcode 62 different paths, leetcode 78 subset, leetcode 33 search rotation sort array (modify dichotomy)
- Leetcode:剑指 Offer 59 - I. 滑动窗口的最大值
- Ouc2021 autumn - Software Engineering - end of term (recall version)
- Test function in pychram
- Force buckle - sum of two numbers
- 家居网购项目
猜你喜欢
pytorch中的双线性插值上采样(Bilinear Upsampling)、F.upsample_bilinear
idea插件备份表
Take you through a circuit board, from design to production (dry goods)
Leetcode 128 longest continuous sequence (hash set)
Feature Pyramid Networks for Object Detection论文理解
How do spark tasks of 10W workers run? (Distributed Computing)
ASGNet论文和代码解读2
Data exchange JSON
ctfshow爆破wp
服务器渲染技术jsp
随机推荐
Cygwin的下载和安装配置
torch. histc
用小程序的技术优势发展产业互联网
pytorch训练深度学习网络设置cuda指定的GPU可见
Use of comment keyword in database
How do spark tasks of 10W workers run? (Distributed Computing)
[小样本分割]论文解读Prior Guided Feature Enrichment Network for Few-Shot Segmentation
md5sum操作
Promise中finally的用法
过滤器 Filter
Subnet division and subnet summary
Edge drawing: a combined real-time edge and segment detector
go实现命令行的工具cli
RSN:Learning to Exploit Long-term Relational Dependencies in Knowledge Graphs
gcc使用、Makefile总结
Thread data sharing and security -threadlocal
C语言多线程编程入门学习笔记
Leetcode 128 longest continuous sequence (hash set)
串口接收数据方案设计
Ridge regression and lasso regression