linux中静态库和动态库的制作与使用

一、静态链接库

1、首先编写模块程序example.c、example.h

2、使用gcc -c example.c -o example.o编译example.c

3、使用命令 ar cqs libexample.a example.o对库进行打包,完成后使用命令 cp libexample.a /usr/lib 完成转移

4、创建test.c文件,编译 gcc  -lexample(指定链接库名称) test.c -o  test  完成。


二、动态链接库

1、首先编写模块程序example.c、example.h

2、使用gcc -c example.c -o example.o编译example.c

3、使用命令gcc  -shared  -fPIC  example.o -o libexample.so,完成后使用命令 cp libexample.so /usr/lib 完成转移

4、创建test.c文件,编译 gcc  -lexample(指定链接库名称) test.c -o  test  完成。



 

相关文章:

  • 2021-06-21
  • 2022-12-23
  • 2021-12-17
  • 2021-11-07
  • 2022-12-23
  • 2021-04-13
  • 2021-05-31
猜你喜欢
  • 2021-06-26
  • 2022-12-23
  • 2021-06-17
  • 2021-06-28
  • 2021-09-18
  • 2021-07-15
相关资源
相似解决方案