Introduction to libraries in Windows and Linux

Source: Internet
Author: User
Article Title: Introduction to libraries in Windows and Linux. Linux is a technology channel of the IT lab in China. Including desktop applications, Linux system management, kernel research, embedded systems and open-source systems.
 
Library files are a collection of pre-compiled functions, which are all written in accordance with reusable principles. They are usually composed of a group of interrelated functions used to complete a common task. Essentially, the Library is a binary form of executable code that can be loaded into the memory for execution by the operating system.
 
A large number of libraries exist on both Windows and Linux platforms. However, because of the differences between Windows and Linux, the binary libraries of the two are incompatible.
 
Database category
 
There are two types of libraries in Windows: static library (. Lib) and dynamic link library (. Dll ).
 
There are two types of libraries in Linux: static libraries (. A) and shared library (. So ).
 
The static library name in Linux is generally libxxxx. a, where xxxx is the name of this lib
 
In Linux, the dynamic library name is generally libxxxx. so. major. minor, xxxx is the lib name, major is the main version, and minor is the minor version.
 
Differences between libraries in Windows and Linux
 
Linux shared library (. So) is like Windows dynamic link library (. Dll), which contains many common functions. To facilitate program development and reduce program redundancy, the program does not need to include copies of each common function, but calls common functions in the shared library when necessary. This method is called Dynamically Linked ). Sometimes we do not want a program to call functions of the shared library, but directly link the library function code to the program code. That is to say, the program itself has a copy of the functions in the shared library. This method is called Statically Linked ).
 
Therefore, the difference between a static library and a shared library (dynamic library) is that the Code is loaded at different times.
 
The code of the static library has been loaded into the executable program during compilation, so the size is large.
 
The code of the shared library is loaded into the memory only when the executable program runs. It is only referenced in the compilation process, so the code size is small.
 
Dynamic Link Library in Windows (. Dll) and Linux shared library (. So) Difference
 
. Dll file actually and. . For implicit reference of external symbols, the position of the external symbols must be written on the PE Header. The PE Loader finds the dependent symbol table from the PE Header and loads other dependent symbols. Dll file.
 
This is not the case in Linux !. Most of the so files are in the elf execution file format. When they need external symbols, they do not indicate the location of these symbols. That is to say, normally. The so file itself does not know which symbols it depends on. So. These symbols are provided by the running process that calls dlopen.
 
Let's create one in Windows. You also need to include one dll file. Lib file. in Linux, only the corresponding header file is required. For writing new. So, the unfound symbol can be there until the final execution file combines all the required symbols. Windows can have one. Dll to another. The implicit dependency of dll, which is not required in Linux. So and. So has an implicit dependency.
 

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.