Dynamic link library DLL, static link library lib, import library Lib

Source: Internet
Author: User
Tags function prototype versions

There are two kinds of libraries with Lib suffix, one is static link library (static libary, hereinafter referred to as "still Library"), and the other is the import library (import libary, hereinafter referred to as "import library") of Dynamic Connection library (DLL, hereinafter referred to as "Dynamic Library").
A static library is a package of one or more obj files, so some people simply refer to the process of generating lib from the obj file as archive, which is merged together. For example, if you link a static library, if there is a mistake, it will find out exactly which obj is wrong, that is, static Lib is just a shell.
The dynamic library usually has the corresponding import library, the convenience program statically loads the dynamic link library, otherwise you may need oneself loadlibary the DLL file, then GetProcAddress obtains the corresponding function manually. With the import library, you only need to link to the import library and follow the declaration of the header file function interface to call the function.
The difference between an import library and a static library is that they are essentially different things. The static library itself contains the actual execution code, symbol table and so on, and for the import library, its actual execution code is located in the dynamic library, the import library contains only the address symbol table, etc., to ensure that the program to find some basic address information of the corresponding function.

This is also in fact a lot of open source code publishing idiomatic way:

1. Precompiled Development Kit: contains some. dll files and some. lib files. One of the. Lib here is the import library, not the wrong way to think of a static library. However, as with static libraries, the path to find these. Lib is added on the link path. The. dll is best placed in the same directory as the last generated application exe executable file. When this is run, the dynamic link library is automatically transferred.

2. The user compiles themselves: The source code is downloaded and compiled according to the readme itself. Generate a library file that is most likely also a. dll +. lib (import library)

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

DLL:
A dynamic-link library (DLL) is an executable file that acts as a library of shared functions. Dynamic linking provides a way for a process to invoke a function that is not part of its executable code. The executable code of the function is in a DLL that contains one or more functions that have been compiled, linked, and stored separately from the processes that use them. DLLs also help to share data and resources. Multiple applications can access the contents of a single copy of a DLL in memory at the same time. The difference between a
dynamic link and a static link is that it allows an executable module (a. dll file or an. exe file) to contain only the information needed to locate the executable code for the DLL function at run time. In a static link, the linker gets all the referenced functions from the static link library and places the library with the code in the executable file.
There are several advantages to using dynamic linking instead of static linking. DLL saves memory, reduces switching operations, saves disk space, is easier to upgrade, provides after-sales support, provides mechanisms to extend the MFC library classes, supports multi-language programs, and makes the creation of international versions easy.

The

API is the application programming interface. It is a set of functions that can be used to manipulate components, applications, or operating systems. Typically, the API consists of one or more DLLs that provide some special functionality. A
DLL is a file that contains functions that can be called by any application running under Microsoft windows. At run time, the function in the DLL is dynamically linked to the application that called 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 calls into memory.
The API you hear most probably is the Windows API, which includes the various DLLs that make up the Windows operating system. Each Windows application interacts directly or indirectly with the Windows API. The Windows API guarantees that all applications running under Windows behave in a consistent manner.
Note with the development of the Windows operating system, several versions of the Windows API are now published. Windows 3.1 uses the Win16 API. Microsoft Windows NT, Windows 95, and Windows 98 platforms use the Microsoft Win32 API.
In addition to the Windows API, some other APIs have also been published. For example, Messaging Application programming Interface (MAPI) is a set of DLLs that you can use to write e-mail applications. The
API is traditionally written for C and C + + programmers who develop Windows applications, but other programming languages, including VBA, can also invoke functions in the DLL. Because most DLLs are written and organized primarily for C and C + + programmers, the method of calling a DLL function differs from calling a VBA function. You must understand how to pass parameters to a DLL function when using the API.
Warning calls to Windows APIs and other DLL functions may adversely affect your application. When you call DLL functions directly from your own code, you bypass some of the security mechanisms that VBA typically provides. If an error occurs when you define or invoke a DLL function (all programmers are unavoidable), you may cause application errors (also known as universal protection errors, or GPF) in your application. The best solution is to save the project before running the code, and be sure to understand the rationale for DLL function calls.

LIB creates standard libraries, import libraries, and export files that you can use with LINK when you build 32-bit programs. LIB runs from the command prompt. The
can use Lib in the following modes:
to generate or modify a COFF library
Extract member objects into a file
Create an export file and import a library
These patterns are mutually exclusive, and LIB can only 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.