当前位置:网站首页>Basic IO (below): soft and hard links and dynamic and static libraries
Basic IO (below): soft and hard links and dynamic and static libraries
2022-08-02 04:56:00 【RNGWGzZs】
"There is no easy,Only the unreached shore"
(1)理解文件系统
①inode:
in the process chapter,我们知道.The system will create multiple processes,need to manage.
The six-character mantra of management: 先描述 再组织
每个进程都有对应的pid,Make it easier for the operating system to manage itself.
So relative to the file,you can find in different directories,can create a file with the same name.本质上,These files are not only identified by the file name.but hidden inode.
inode 就 类似于 进程的 pid
ls -l -i //带上-i 选项 查看 文件的inode
那么inode where do the numbers come from??
②Disk partition:
磁盘是典型的块设备,and almost the only mechanical equipment.
disk storage partition:
分区 | 作用 |
超级块(Super Block) | 记录的信息主要有:bolck 和 inode的总量, 未使用的block和inode的数量,一个block和inode的大小,最 |
块组描述符(GDT) | 描述块组属性信息 |
块位图(Block Bitmap) | 记录Data blockWhich piece of data is occupied Which piece of data is not occupied |
inode位图(inode Bitmap) | 每个bit表示一个inode是否空闲可用 |
inode table | original file information |
Data block | 数据区 |
(2)软硬链接:
①How to understand hard links?
我们知道,The real file on the disk is not the filename,而是inode. 然而在linux下,Multiple file names can correspond to the sameinode.
ln +目标文件 +当前文件 // 硬链接
ln + (-s) //软连接
The fundamental difference between hard and soft link:
Hard links do not generate new onesinode,Also, it is not a separate file.
Soft link will be newly created 新的 inode ,是一个独立的文件.
We delete separately hard and soft link 原文件:
The original file is “干掉”:
软链接的 The file can no longer be used.
硬链接 Can continue to use the file.
②inode中的ref
struct inode
{
int ret; //引用计数
}
在dycreate another directoryclass 目录后:
也就是说,hardwired properties 是在包括“." "..”,When creating another inside the directory class.
③ACM文件时间;
stat + 文件名
Access;最后访问时间
Modify;文件最后修改时间
Change;属性修改时间
(3)动静态库:
①动静态库
linux下
静态库; .a
动态库; .so
win下;
动态库:.dll
静态库: .lib
②Dynamic and static library features:
静态:
①static library linking because 在编译时,All code needs to be loaded into memory.占用空间很大(内存+磁盘)
②When calling the same static library,会出现重复代码.代码冗余.
动态:
依赖动态库.No library will not be able to use library content.
③如何制作动静态库?
静态库:
We make dynamic and static libraries,只需要把头文件、.oJust pack the file.
//Makefile
//mylib 是 libcal.a的别名
//CC 是gcc的别名
mylib=libcal.a
CC=gcc
//编译mylib 也就是 libcal.a
$(mylib):add.o sub.o
ar -rc $(mylib) $^ //here is a must!!!
//%. 通配符
%.o:%.c
$(CC) -c $<
.PHONY:clean
clean:
rm -rf $(mylib) *.o
rm -rf mathlib
//创建目录 并把编译好的.o .h copy directory
.PHONY:output
output:
mkdir -p mathlib/lib
mkdir -p mathlib/include
cp *.h mathlib/include
cp *.a mathlib/lib
我们需要的就是 把mathlib Just throw it away.
此时我们对 文件进行编译.发现无法找到<add.h>的头文件.
这很好理解.
The compiler can only search in the default path.
//编译
gcc +(mytest.c) -I 头文件 -L 库路径 -l specific library
We generate a static library.
动态库:
Same as static library;
但编译.c \.so文件;
//.c -> .o gcc -fPIC //.o -> libcal.so gcc -shared
.o生成
libcal.so
We successfully compiled the file But why don't run up?!
根本上,编译和执行是分离的,One is to hand over to the compiler,The other is to hand over to the operating system
We tell the compiler only 这个mytest.cwhere are the library files for. 但是 When the file is run and becomes,The operating system cannot find the library file!!
导入环境变量:
echo$ LD_LIBRARY_PATH:System library default path
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:+库的绝对路径
导入前:
导入后,执行了.
总结:
①inode作为文件标识符.Can be pointed to by multiple files at the same time.
②软链接会创建新的inode 反而 Hard links do not
③静态库制作:
ar -rc
-I -L -l
④动态库制作:
-fPIC
-shared
-l
This is the end of this article~
感谢你的阅读.
祝你好运~
边栏推荐
- 开源代码交叉编译操作流程及遇到的问题解决(lightdm)
- 龙讯LT6911系列C/UXC/UXB/GXC/GXB芯片功能区别阐述
- 振芯GM7123C:功能RGB转VGA芯片方案简介
- GM8284DD,GM8285C,GM8913,GM8914,GM8905C,GM8906C,国腾振芯LVDS类芯片
- 实现动态库(DLL)之间内存统一管理
- uniCloud address book combat
- 【Arduino connects SD card module to realize data reading and writing】
- 2020 - AAAI - 图像修复 Image Inpainting论文导读 -《Region Normalization for Image Inpainting》
- NSIS来自己设定快捷方式的图标
- GM7150 CVBS转BT656视频解码芯片详细内容及设计要求
猜你喜欢
振芯科技GM8285C:功能TTL转LVDS芯片简介
Lightly:新一代的C语言IDE
GM8775C MIPI转LVDS调试心得分享
【plang1.4.3】编写水母动画脚本
LL(1)文法 :解决 if-else/if-else 产生式二义性问题
I2C无法访问ATEC508A加密芯片问题
Introduction and mock implementation of list:list
[Popular Science Post] I2C Communication Protocol Detailed Explanation - Partial Software Analysis and Logic Analyzer Example Analysis
滑动窗口方法
【科普贴】I2C接口详解——偏硬件解析
随机推荐
Application of electronic flow on business trip
最第k大的数的一般性问题
Cadence allegro导出Gerber文件(制板文件)图文操作
分割回文串 DP+回溯 (LeetCode-131)
Introduction and mock implementation of list:list
vector的使用和模拟实现:
【TCS3200 color sensor and Arduino realize color recognition】
【plang1.4.3】语言新特性:集合
Basic IO (on): file management and descriptors
引擎开发日志:场景编辑器开发难点
TC358860XBG BGA65 东芝桥接芯片 HDMI转MIPI
78XX 79XX多路输出电源
蛮力法求解凸包问题
path 修补文件命令
2020 - AAAI - Image Inpainting论文导读《Learning to Incorporate Structure Knowledge for Image Inpainting》
MC1496乘法器
How to remotely debug PLC?
USB2.0一致性测试方法_高速示波器
AD8361检波器
idea中创建jsp项目详细步骤