Linux learning jottings(2)-static or dynamic library

function library is divided into static library and dynamic library.


0x00. static function library

  • it was compiled into target file, so, its not needed at runtime.
  • Obviously, when the static library modified, you should recompile the application.
  • for example:

Makefile

hello: main.c libhello.a
gcc -o hello main.c -L. -lhello
libhello.a: hello.o
ar cr libhello.a hello.o
hello.o: hello.c
gcc -c hello.c
```

  • libhello.a removed or not does not make any difference on the running of "hello"

0x01. dynamic function library

  • create dynamic function library
gcc -shared -fPCI -o libhello.so hello.o

0x02.

原文地址:https://www.cnblogs.com/takeoffyoung/p/5347692.html