Dynamic Link Library DLL, static Link Library Lib, import library lib to convert

Source: Internet
Author: User
Tags import database

Dynamic Link Library DLL, static Link Library Lib, and imported library lib

When compiling a project with vs, we will choose dynamic link library DLL, static Link Library lib (static library ), but why can I specify the output lib when compiling the dynamic link library? What is the use of this lib?

The following article tells us the answer. This article comes from: http://www.cnblogs.com/chio/archive/2008/08/05/1261296.html.

Currently, there are two types of libraries with the Lib Suffix: static libary (hereinafter referred to as "static library") and dynamic connection library (DLL, import libary (hereinafter referred to as "Import Database ").
The static library is a package of one or more OBJ files, so someone simply calls the process of generating lib from the OBJ file archive, that is, merging it together. For example, if you link a static library, if there is a mistake in it, it will accurately find which obj is wrong, that is, static Lib is only a shell.
A dynamic library usually has a corresponding Import and Export library, which facilitates the program to load the dynamic link library statically. Otherwise, you may need to load the DLL file by yourself, and then manually getprocaddress to obtain the corresponding function. With the import/export function, you only need to link the import/export function and call the function according to the declaration of the header file function interface.
Import-to-database and static databases are very different. They are actually different. The static library itself contains the actual execution code, symbol table, and so on. For the import and export operations, the actual execution code is in the dynamic library, and the import and export operations only contain the address symbol table, make sure that the program finds some basic address information of the corresponding function.

This is actually a common method for many open-source code releases:

1. Pre-compiled Development Kit: contains some. DLL files and some. Lib files. Here,. Lib is imported to the database, instead of being a static database. However, the method of introduction is the same as that of static libraries. You must add these. Lib paths to the link path. While. dll is better placed in the directory where the generated application EXE execution file is the same. In this way, the dynamic link library is automatically transferred to the runtime.

2. Compile by yourself: the source code is downloaded and compiled by readme. It is likely to generate library files for. dll +. Lib (import to database ).

3. If you only have DLL, and you know the function prototype of the DLL function, you can directly use loadlibary in your own program to call the DLL file, getprocaddress

DLL:
A dynamic link library (DLL) is an executable file used as a shared function library. Dynamic links provide a way for a process to call a function that does not belong to its executable code. The executable code of a function is located in a DLL, which contains one or more functions that have been compiled, linked, and stored separately from the processes that use them. DLL also helps to share data and resources. Multiple applications can simultaneously access the content of a single DLL copy in the memory.
The dynamic link differs from the static link in that it allows the executable module (. dll file or. EXE file) to only contain the information required to locate the executable code of the DLL function at runtime. In a static link, the linker obtains all referenced functions from the static Link Library and puts the library together with the code into the executable file.
Using Dynamic Links instead of static links has several advantages. DLL saves memory, reduces swap operations, saves disk space, makes it easier to upgrade, provides after-sales support, and extends the MFC Library Class mechanism to support multi-language programs, and make it easy to create international versions.

An API is an application programming interface. It is a group of functions that can be used to operate components, applications, or operating systems. In typical cases, an API is composed of one or more DLL that provides certain special functions.
DLL is a file, which is contained in Microsoft? Windows? Function that can be called by any application running under. During runtime, the functions in the DLL are dynamically linked to the application that calls it. No matter how many applications call a function in the DLL, only one file on the disk contains the function and the DLL is created only when it is transferred to the memory.
The most frequently-heard API may be a Windows API, which includes various DLL that constitute the Windows operating system. Every windows application interacts directly or indirectly with Windows APIs. Windows API ensures that all applications running in Windows behave in the same way.
Note that with the development of the Windows operating system, several versions of Windows APIs have been released. Windows 3.1 uses the Win16 API. Microsoft? Windows NT? Windows 95 and Windows 98 use Microsoft? Win32? API.
In addition to Windows APIs, other APIs have also been released. For example, the Mail Application Programming Interface (mapi) is a set of DLL that can be used to write email applications.
APIs are traditionally written for C and C ++ programmers who develop Windows applications. However, other programming languages (including VBA) can also call functions in DLL. Because most of the DLL files are mainly written and organized for C and C ++ programmers, the method for calling the DLL function is different from that for calling the VBA function. When using APIs, you must understand how to pass parameters to DLL functions.
Warning calling Windows APIs and other DLL functions may adversely affect your applications. When calling DLL functions directly from your own code, you bypass some of the security mechanisms commonly provided by VBA. If an error occurs when defining or calling a DLL function (which is unavoidable by all programmers), it may cause an application error (also known as a universal protection error or GPF) in the application ). The best solution is to save the project before running the Code and ensure that you understand the principle of DLL function calling.

Lib creates a standard library, imports and writes to the database, and exports files. It can be used with link when a 32-bit program is generated. Run lib from the command prompt.
You can use Lib in the following modes:
Generate or modify the coff Library
Extract Member objects to files
Create exported files and import them to the database
These modes are mutually exclusive. Only lib can be used in one mode at a time.

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.