当前位置:网站首页>About Library (function library), dynamic library and static library
About Library (function library), dynamic library and static library
2022-06-30 10:34:00 【Fat Xiao Deng】
Make dynamic library , Static library , I have some understanding , At the same time, it is also convenient for me to check my notes in the future , If there is a mistake , Please comment , thank you !
library ( function library ):
Function library is a collection of functions with certain functions established by the system . The library stores the name of the function and the corresponding object code , And relocation information required during connection . Users can also create their own user function library according to their own needs . ( Convenient to call , And encrypt the code )
Be careful : Function functions are stored in the library , Don't put main Functions are encapsulated .
Dynamic library (libname.so):
characteristic :
(1) When compiling an executable using functions in the library , It does not compile the code in the library . Programs compiled with dynamic libraries are relatively small .
(2) Executable compiled by dynamic library , This dynamic library is required in the system environment variable during execution , Otherwise, it cannot run .
Make :gcc -shared -fPIC -o lib Library name .so .c .c …
.c .c …: All function functions .c file
shared: To generate .so Dynamic library files
-fPIC: -fPIC Works in the compilation phase , Tell the compiler to generate location independent code (Position-Independent Code), In the generated code , No absolute address , All use relative addresses , Therefore, the code can be loaded anywhere in memory by the loader , Can be executed correctly . This is what shared libraries require , When the shared library is loaded , The location in memory is not fixed .
Each library has one or more corresponding header files
(1) compile
gcc .c -o Executable file name -I( Big i) Follow file path -L Follow the library file path -l( A lowercase letter l) Library name
.c : The main function .c file
Executable file name : Suggested main function name _so, It is convenient to know which file is generated in the future
-I( Big i) Follow file path : Link header file
-l( A lowercase letter l) Library name : -l There is no space between the database name and the previous one
Library name : Do not prefix lib, And no suffix .so
This dynamic library is available in the system environment variable Copy the dynamic library to /lib or /usr/lib in
(2) perform
./ Executable file name
Static library (libmame.a):
characteristic :
(1) When compiling an executable using functions in the library , Will replace Code is compiled into . Programs compiled with static libraries are relatively large .
(2) Executable compiled by static library , This library is not required in the system environment variable during execution , It can also run .
Make :gcc .c -o .o -c
①.c: every last .c, Can only be generated one by one .o file
②ar cr lib Library name .a .o .o … -c
ar : Packaging tools Can be used to create , Modify library file , Extract from the library file Of .o modular
c : One option , Represents creating a library , Create a library file whether it exists or not .
r : One option , It means that you will .o Insert the module into the library .
.o .o …: All function functions .c File generated .o Redirectable files
(1) compile
gcc .c -o Executable file name -I( Big i) Follow file path -L Follow the library file path -l( A lowercase letter l) Library name -static( See the following precautions )
Executable file name : Suggested main function name _a, It is convenient to know which file is generated in the future
-I( Big i) Follow file path : Link header file
-l( A lowercase letter l) Library name : -l There is no space between the database name and the previous one
Library name : Do not prefix lib, And no suffix .a
Be careful : There are dynamic libraries and static libraries under the current path , The dynamic library will be compiled by default first , In order to compile with a static library, you need to add -static
(2) perform
./ Executable file name
边栏推荐
- 我的远程办公深度体验 | 社区征文
- Skill combing [email protected] somatosensory manipulator
- R语言aov函数进行重复测量方差分析(Repeated measures ANOVA、其中一个组内因素和一个组间因素)、分别使用interaction.plot函数和boxplot对交互作用进行可视化
- "Kunming City coffee map" activity was launched again
- Gd32 RT thread RTC driver function
- 技能梳理[email protected]體感機械臂
- mysql数据库基础:约束、标识列
- 马斯克推特粉丝过亿了,但他在线失联已一周
- R language plot visualization: use plot to visualize the prediction confidence of the multi classification model, the prediction confidence of each data point of the model in the 2D grid, and the conf
- Basic MySQL operation commands of database
猜你喜欢

KOREANO ESSENTIAL打造气质职场范

Koreano essential creates a professional style

The digital collection of sunanmin's lotus heart clearing was launched on the Great Wall Digital Art

郭琳加冕 2022第三季完美大师 全球人气季军

Criu enables hot migration
[email protected]+adxl345+电机震动+串口输出"/>技能梳理[email protected]+adxl345+电机震动+串口输出

光明行动:共同呵护好孩子的眼睛——广西实施光明行动实地考察调研综述

移植完整版RT-Thread到GD32F4XX(详细)
[email protected]在oled上控制一条狗的奔跑"/>技能梳理[email protected]在oled上控制一条狗的奔跑

The preliminary round of the sixth season of 2022 perfect children's model Hefei competition area was successfully concluded
随机推荐
Yixian e-commerce released its first quarterly report: adhere to R & D and brand investment to achieve sustainable and high-quality development
技能梳理[email protected]在oled上控制一条狗的奔跑
[ark UI] implementation of the startup page of harmoniyos ETS
孙安民作品《莲花净心》数字藏品上线长城数艺
mysql数据库基础:约束、标识列
Action bright: take good care of children's eyes together -- a summary of the field investigation on the implementation of action bright in Guangxi
Questions about cookies and sessions
我在鹅厂淘到了一波“炼丹神器”,开发者快打包
Test memory read rate
RobotFramework学习笔记:环境安装以及robotframework-browser插件的安装
ArcGIS Pro脚本工具(5)——排序后删除重复项
Automated stock trading ensemble strategy based on Reinforcement Learning
MySQL index, transaction and storage engine of database (1)
GD32 RT-Thread DAC驱动函数
MySQL index, transaction and storage engine of database (2)
技能梳理[email protected]语音模块+stm32+nfc
跳跃表介绍
MySQL index, transaction and storage engine of database (3)
SGD有多种改进的形式,为什么大多数论文中仍然用SGD?
移植完整版RT-Thread到GD32F4XX(详细)