LIB、DLL及C++的编译过程

本文详细解释了静态库(LIB)和动态库(DLL)的区别。静态库主要用于避免重复编译常用函数,而动态库则实现了多个程序共享同一份库函数的功能,节省内存占用。此外还介绍了C++编译过程的相关知识。

 

1、LIB,DLL

       1)LIB:静态库只是在编译过程中用到。将一些通用方法率先编译到静态库中,例如某一个通用函数方法在程序中多处被用到,那么这个通用函数就可以率先被编译到静态库中。

       Libraries are used because you may have code that you want to use in many programs. For example if you write a function that counts the number of characters in a string, that function will be useful in lots of programs. Once you get that function working correctly you don't want to have to recompile the code every time you use it, so you put the executable code for that function in a library, and the linker can extract and insert the compiled code into your program.

     2)DLL:动态库只是在运行的过程中用到,配合可执行文件一起运行。DLL是为了解决可执行文件中函数堆叠的问题。动态库编译的是具体执行函数的方法,需运行在内存中的,结合静态库中的通用函数再次进行编译内容。用Depends可进行查询。

        Dynamic libraries take this one step further. It seems wasteful to have multiple copies of the library functions taking up space in each of the programs. Why can't they all share one copy of the function? This is what dynamic libraries are for. Rather than building the library code into your program when it is compiled, it can be run by mapping it into your program as it is loaded into memory. Multiple programs running at the same time that use the same functions can all share one copy, saving memory. In fact, you can load dynamic libraries only as needed, depending on the path through your code. No point in having the printer routines taking up memory if you aren't doing any printing. On the other hand, this means you have to have a copy of the dynamic library installed on every machine your program runs on. This creates its own set of problems.

 

C++的编译过程:http://www.cnblogs.com/dongdongweiwu/p/4743709.html

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值