Linux function library creation method

  

The function library under Linux has static library and dynamic library. There are certain differences between the two. The main reason is that the code loading time is different. The following small series introduces you to the Linux static library and Create a dynamic library, let's learn together.

static and dynamic library creation and use

1. Basic concepts

static library: link, packaged together with the library compiled .o files Go to the executable. The extensions under linux /windows are: .a /.lib

Dynamic library: When linking, it will not be packaged into the executable file, and the dynamic library will be dynamically loaded during execution. The extensions under linux /windows are: .so /.dll

The difference is mainly reflected in:

a, maintainability.

Join the update. To incorporate updates to the dynamic library, just replace the library. However, if you join static, you need to relink, generate a new executable, and update it in full.

Environmental dependence. If you include a static library, it does not depend on the environment after successful compilation. Dynamic libraries have dependencies and require corresponding dynamic libraries in the environment.

b, size

space utilization. If you rely on the same static library, there are multiple copies.

Executable file size. The static library file is large.

c, dynamic library can achieve resource sharing between processes, so it is also called shared library.
Previous12Next Total 2 Pages

Copyright © Windows knowledge All Rights Reserved