Linux-Dynamic (static) function library

Source: Internet
Author: User

The first thing we need to know is, what are the types of libraries? According to the type of function library being used, it is divided into two categories, namely static and dynamic function libraries.

Features of the static function library:

Extension: (extension. a)
This type of function library usually has a name extension of libxxx.a;

Compile behavior:
This type of library will be compiled directly into the running program, so the use of static library compiled into the file will be a little more oh;

State of independent Operation:
The great advantage of this type of library is that the successful running files can run independently without the need to read the contents of the library to external requirements (see the description of the dynamic function library).

Ease of Upgrade:
Although the run file can be run independently, because the function library is directly integrated into the run file, if the function library is upgraded, the entire run file must be recompiled to incorporate the new library into the program. That is, in terms of upgrading, all the programs that incorporate this library need to be recompiled as long as the library is upgraded!


Features of the dynamic function library:

    Extension: (extension. So)
     This type of function library usually has a libxxx.so extension;

     compile behavior:
& nbsp The compilation behavior of the    dynamic function library and the static function library is quite different. and static function library is the entire catch to the program, the dynamic function library at compile time, in the program there is only a "point (Pointer)" location. In other words, the contents of the dynamic function library are not integrated into the run file, but are used by the program to read the function library when it uses the mechanism of the function library. Since the run file has only the indicator pointing to the dynamic function library and does not contain the contents of the library, his file will be smaller.

     standalone state:
     programs compiled by this type of function library cannot be run independently, because when we use the mechanism of a function library, the program will read the library. Therefore, the function library file "must exist" only, and, the function library "directory also cannot change", because our can run the document only "the indicator" namely when wants to take the dynamic function library, the program will take the initiative to go to a certain path to read, hehe! So the dynamic function library can not be arbitrarily moved or deleted, will affect a lot of dependent program software Oh!

     Ease of upgrade:
     Although this type of run file cannot run independently, it has the function of pointing to it, so when the library is upgraded, The run file does not need to be recompiled at all, because the run file points directly to the new library file (provided the file name of the new and old version of the library is the same!). )。

The current Linux distribution is more inclined to use a dynamic function library, because as the most important point mentioned above, it is convenient to upgrade the function library! Because of the complexity of software dependencies in Linux systems, if you use too many static libraries, you will have a great impact on the whole system if you upgrade a library of functions. Because other dependent run files must also be recompiled at the same time! This time the dynamic function library is much more useful, because as long as the dynamic function library upgrade is good, the other software does not need to change at all.

The vast majority of libraries are placed in:/usr/lib,/lib directory! In addition, many of the functions in the Linux system are actually provided by kernel, then the kernel library is placed in/lib/modules! There is more data in it! It is important to note, however, that the different versions of the core provide a very large difference in the function library.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Linux-Dynamic (static) function library

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.