Newbie School: Introduction to libraries in Windows and Linux

Source: Internet
Author: User
What is a library file is a collection of pre-compiled functions, which are written in accordance with the reusable principles. They are usually composed of a group of interrelated letters used to complete a common task.

What is a database?

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 library (. dll ).

There are two types of libraries in Linux: static library (. 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.

Differences between dynamic link library (. dll) in Windows and shared library (. so) in Linux

The. dllfile and the. exe file are the same as the execution files in PE format. 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. dll files.

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, the. so file does not know which. so symbols it depends on. These symbols are provided by the running process that calls dlopen.

We also need to carry a. lib file when creating a. dll file in Windows. in Linux, only the corresponding header file is required. For writing a new. so file, you can leave it there until the final execution file combines all the required symbols. In windows, one. dll can be implicitly dependent on another. dll. in Linux, implicit dependency between. so and. so is generally not required.

Related Article

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.