Linux builds using dynamic libraries and static libraries

Source: Internet
Author: User

Linux has two types of function libraries, dynamic libraries and static libraries

Static Library:

This type of library is typically a file with a suffix of. A, and a file compiled with a static library function is larger because all of the data in the library is integrated into the target code.

The compiled execution program does not require external function library support, but it has its drawbacks that once the static function library has changed, the program must be recompiled.

Dynamic Library:

This type of library is generally called. So as the suffix, and in contrast to the static library function library, the dynamic function library is not compiled into the target code. When the program executes to the correlation function, only then calls the function library's corresponding function, therefore the dynamic library function library produces the executable file to be relatively small, because the function library is not to be integrated in the program, therefore this also has less static library lock the shortcoming.

The system default library in Linux system has/lib/usr/lib/usr/local/lib

Whatever library file is generated by the. o file.

Now I'm going to explain the next two kinds of library generation methods and procedures:

Dynamic Library:

Execute the following command on the file that bites the build library:

#gcc-shared Funname.c-o liblibname.so

Static Library:

#gcc-C funname.c

#ar CR Liblibname.a FUNNAME.O

Severity FUNNAME.O is the first step of the file generated

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.