当前位置:网站首页>分享一个通用的so动态库的编译方法
分享一个通用的so动态库的编译方法
2022-07-06 17:32:00 【wandersky0822】
CC :=$(CROSS_COMPILE)gcc
LD :=$(CROSS_COMPILE)ld
CFLAGS := -fPIC -Wall
LDFLAGS := -shared -Wl,-soname=libdrdev.so.2
SOURCE := $(wildcard *.c)
OBJS := $(patsubst %.c,%.o,$(SOURCE))
TARGET_LIB := libdrdev.so.2.1.0
all:$(OBJS)
@echo $(OBJS)
# $(LD) $(LDFLAGS) -o $(TARGET_LIB) $(OBJS)
$(CC) $(LDFLAGS) -o $(TARGET_LIB) $(OBJS)
%.o:%.c
@echo Compiling $< ...
$(CC) -c $(CFLAGS) $< -o $*.o
.PHONY:clean
clean:
rm $(TARGET_LIB) *.o -rf
几个知识点,解释如下:
-fPIC 位置无关
-shared 顾名思义,生成共享库
$(wildcard *.c) 在文件夹下列出所有.c 文件
$(patsubst %.c,%.o,$(SOURCE)) 在$(SOURCE)中查找.c文件,替换为.o
%.o:%.c %通配符,猜也能猜个差不多
$< 所有依赖
$* 所有目标%之前的部分。
边栏推荐
- Let's talk about 15 data source websites I often use
- go-zero微服务实战系列(九、极致优化秒杀性能)
- A brief history of deep learning (I)
- 【案例分享】网络环路检测基本功能配置
- Do you understand this patch of the interface control devaxpress WinForms skin editor?
- [100 cases of JVM tuning practice] 05 - Method area tuning practice (Part 2)
- Dell Notebook Periodic Flash Screen Fault
- Data type of pytorch tensor
- ARM裸板调试之JTAG调试体验
- Segmenttree
猜你喜欢
Do you understand this patch of the interface control devaxpress WinForms skin editor?
pytorch之数据类型tensor
Segmenttree
The MySQL database in Alibaba cloud was attacked, and finally the data was found
Tensorflow GPU installation
重上吹麻滩——段芝堂创始人翟立冬游记
Data type of pytorch tensor
线段树(SegmentTree)
筑梦数字时代,城链科技战略峰会西安站顺利落幕
Windows installation mysql8 (5 minutes)
随机推荐
深度学习框架TF安装
Asset security issues or constraints on the development of the encryption industry, risk control + compliance has become the key to breaking the platform
动态规划思想《从入门到放弃》
What kind of experience is it to realize real-time collaboration in jupyter
C# 计算农历日期方法 2022
c语言—数组
Oracle:CDB限制PDB资源实战
Address information parsing in one line of code
Informatics Olympiad YBT 1171: factors of large integers | 1.6 13: factors of large integers
[case sharing] basic function configuration of network loop detection
Supersocket 1.6 creates a simple socket server with message length in the header
Installation and testing of pyflink
Segmenttree
Mongodb client operation (mongorepository)
table表格设置圆角
NEON优化:矩阵转置的指令优化案例
Installation and testing of pyflink
【案例分享】网络环路检测基本功能配置
Deeply explore the compilation and pile insertion technology (IV. ASM exploration)
Part V: STM32 system timer and general timer programming