Library introduced in [reprint] Windows and Linux systems

Library introduced in Windows and Linux systems

 

Defined library

The library is a collection of pre-compiled function, those functions are in accordance with the principle of reusable written. They are usually composed of a particular function used to complete a set of common tasks associated with each other, essentially form library is a binary executable code can be executed by the operating system into memory.

Whether on the Windows platform or Linux platform, there are a large number of libraries, but because of the different nature of Windows and Linux, so the binary libraries of the two are not compatible.

Class libraries

Library under Windows, there are two: a static library (.lib) and dynamic link libraries (.dll).

Libraries under Linux, there are two: a static library (.a) and shared libraries (.so).

Name static library for Linux is generally libxxxx.a, where xxxx is the name of the lib

The name of the dynamic library under Linux is generally libxxxx.so.major.minor, xxxx is the name of the lib's, major is the major version number, minor is the minor version number.

Similarities and differences between the library and the library under Linux under Windows

Linux shared library (.so) as Windows dynamic link library (.dll), it contains a lot of programs have common functions. In order to facilitate program development and reduce redundancy procedures, procedures which do not contain a copy of each of the commonly used functions, just call shared library functions can often when needed. In this way we call a dynamic link (Dynamically Linked). And sometimes we do not want the program to call the function call shared library, but the library function code is linked directly into the program code, that is, the program itself has a copy of the shared library function. In this way we call static linking (Statically Linked).

So, simply say static and shared libraries (DLL) difference is that different code is loaded at the moment.

Code static library has been loaded executable program during compilation, and therefore larger.

Shared library code is loaded into memory only when running the executable program, only simple reference in the compilation process, and therefore a smaller code size.

Differences in the dynamic link library under Windows (.dll) shared library (.so) under Linux

In fact .dll files and .exe files, belong PE executable file format. For implicit references to external symbols, you need to write the location where the external symbols in the PE head. PE PE loader from head to find the dependence of the symbol table and load other .dll files rely on.

And is not the case on Linux! .so file mostly elf executable file format. When they need external symbols, you may not specify the location of these symbols are located. That usually .so file itself does not know it depends on what those symbols inside the .so. These symbols are provided run by the calling process when dlopen.

We did a .dll file in Windows will also be required to carry a .lib file; and in Linux, only to have the appropriate header files is enough. For the preparation of a new .so, you can not find the symbol on it there until the final executable file to the needs of all symbols joint together. There may be another windows .dll implicit reliance on a .dll; but generally do not need to let the Linux .so and .so there are implicit dependencies.

Permanent link to this article update: http://embeddedlinux.org.cn/emb-linux/entry-level/200903/12-553.html

Guess you like

Origin www.cnblogs.com/jinanxiaolaohu/p/11361099.html