当前位置:网站首页>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 .
边栏推荐
- How to achieve 0 error (s) and 0 warning (s) in keil5
- Avalanche problem and the use of sentinel
- Server rendering technology JSP
- JS daily development tips (continuous update)
- Subnet division (10)
- 过滤器 Filter
- Leetcode 128 longest continuous sequence (hash set)
- [reading notes] copywriting realization -- four golden steps for writing effective copywriting
- 10、Scanner.next() 无法读取空格/indexOf -1
- Cygwin的下载和安装配置
猜你喜欢

Pyramid Scene Parsing Network【PSPNet】论文阅读

4、【WebGIS实战】软件操作篇——数据导入及处理

雪崩问题以及sentinel的使用

还在浪费脑细胞自学吗,这份面试笔记绝对是C站天花板

终极套娃 2.0 | 云原生交付的封装

Introduction to EtherCAT

The preorder traversal of leetcode 144 binary tree and the expansion of leetcode 114 binary tree into a linked list

排序链表(归并排序)

Basic concepts of database

Feature Pyramid Networks for Object Detection论文理解
随机推荐
pytorch nn.AdaptiveAvgPool2d(1)
LeetCode 31下一个排列、LeetCode 64最小路径和、LeetCode 62不同路径、LeetCode 78子集、LeetCode 33搜索旋转排序数组(修改二分法)
复习专栏之---消息队列
Pyramid scene parsing network [pspnet] thesis reading
Are you still wasting brain cells for self-study? This interview note is definitely the ceiling of station C
Leetcode 1818 absolute value, sorting, dichotomy, maximum value
[小样本分割]论文解读Prior Guided Feature Enrichment Network for Few-Shot Segmentation
C语言多线程编程入门学习笔记
不用加减乘除实现加法
Feign remote call and getaway gateway
文件上传下载
数据交换 JSON
Appium自动化测试基础--补充:C/S架构和B/S架构说明
Edlines: a real time line segment detector with a false detection control
torch. histc
Edge Drawing: A combined real-time edge and segment detector 翻译
ECMAScript 6.0
C#实现基于广度优先BFS求解无权图最短路径----完整程序展示
Include() of array
5. [WebGIS practice] software operation - service release and permission management