Linux Learning--dynamic link library and static link library

Source: Internet
Author: User

Tag: Call command to generate Conf learning kernel. So through the directory

Static link libraries:

When the user builds the executable, it calls the library file that ends with. A

Dynamic Link library:

A library file that ends in. So/.so.1.xxx is called when the user builds the executable file

The static library file compiles to the executable file at compile time, so you can run it without relying on the static library file, which causes the resulting executable file to be too large.

Static libraries are not included in the executable at compile time, usually at run time, the corresponding dynamic library files need to be copied together to perform normally, but the executable file is generally small.

The shared library generated by. La for Libtool is actually a configuration document. Can be viewed with file or vim.

The. ko file is the dynamic link file suffix used by the Linux kernel and belongs to the module file, which is used to load the kernel module when the Linux system starts.

Create and build a library file

1, gcc-c test.c generate. O Object File

2, Ar-r libtest.a test1.o test2.o generate libtest.a Static library file

3, gcc-wall-fpic-shared test1.c test2.c-o libtest.so generate dynamic library file

4. La Library is generally generated by makefile.

GCC Test.c-o TEST-I/USR/LOCAL/INCLUDE-L/USR/LOCAL/LIB-LA-LB-LC

GCC Test.c-o test-i/usr/local/include/usr/local/lib/liba.a/home/usr/local/lib/libb.a/home/usr/local/libc.a

./configure cflags= "-i/usr/local/include" ldflags= "-l/usr/local/lib" equivalent to export cflags= "$CFLAGS:/usr/local/include" ; Ldflags= "$LDFLAGS:/usr/local/lib"

Multiple static files are linked into a static file:

The structure of the. A file is no different from the. tar file. The x command is solved, a command is added, and the T command list
Suppose A.a, B.A C.A under the/usr/local/lib directory
Mkdir/tmp/libabc
Cd/tmp/libabc
Ar x/usr/local/lib/a.a
Ar X/USR/LOCAL/LIB/B.A
Ar x/usr/local/lib/c.a
Ar Cru LIBABC.A *.o
Ranlib LIBABC.A

Linux Learning--dynamic link library and static link 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.