Lib static Link Library and DLL Dynamic Link Library

Source: Internet
Author: User

DLL: Dynamic Link Library.

DLL is a complete compiled program. It has been linked to function export tables and import tables. You can call the functions directly during use. DLL is linked only when the program is running, but does not participate in project compilation. Therefore, it is a relatively small executable file format. DLL has other file formats, such as OCX. All DLL files are executable.

Lib is just a code set. It makes some functions into a function set and puts them together. These functions are not linked. If you call functions in Lib, these functions will be compiled during project compilation. Compared with dynamic link library DLL, lib files are also called static link libraries. When using a function in the Lib file, it must contain the header file corresponding to the function and be referenced in the Lib file to allow the compiler to find the compiled binary code.

To put it simply, the static library directly links the required code to the executable program. The dynamic library finds the function based on the function ing table and calls it to the stack for execution. If there are multiple calls to the same function in the DLL file in the current project, this function will only be copied when executed. However, if multiple calls are made to the same function in the Lib file, the function will be copied in multiple copies in the execution space of the current program during execution, in addition, a copy is generated for a single call.

The LIB file itself is relatively large, but it does not need to be attached with DLL; the DLL file itself is relatively small, but it must be accompanied with Lib.

In addition to directly linking the Lib file of the executable program, there is also a lib file that can be viewed as an attachment to the corresponding DLL file. If a DLL file is separated from the code to replace the static Connection Library, a lib file will still be generated. This lib file will be connected to the program to inform the operating system of the DLL file to be used during running. This lib file is actually not a real function set. The exported and imported functions in it are jump commands corresponding to the corresponding location in the DLL file, to call the DLL function when executing an external program. Generally, this lib file has the same name as the corresponding DLL file, and an ordered table that specifies the DLL output function entry.

 

In general, the most important trouble with LIB files is the occurrence of unresolved symble errors, which means that the Lib file connection error or the. C and. cpp files are not included in the project. Especially if the Lib file written in C language is used in the C ++ project, it must include:

Extern "C"

{

# Include "myheader. H"

}

This is because the Lib file written in C language is not damaged by the name required by C ++, and the c function cannot be overloaded. Therefore, the connector will fail.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.