当前位置:网站首页>分享一个通用的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 %通配符,猜也能猜个差不多
$< 所有依赖
$* 所有目标%之前的部分。
边栏推荐
- View remote test data and records anytime, anywhere -- ipehub2 and ipemotion app
- Fastdfs data migration operation record
- SuperSocket 1.6 创建一个简易的报文长度在头部的Socket服务器
- 免费白嫖的图床对比
- Taro中添加小程序 “lazyCodeLoading“: “requiredComponents“,
- Dell筆記本周期性閃屏故障
- Case development of landlord fighting game
- 如何管理分布式团队?
- Dynamic planning idea "from getting started to giving up"
- Link sharing of STM32 development materials
猜你喜欢

Lldp compatible CDP function configuration

Telerik UI 2022 R2 SP1 Retail-Not Crack

Provincial and urban level three coordinate boundary data CSV to JSON

HMM 笔记
![[Niuke] b-complete square](/img/bd/0812b4fb1c4f6217ad5a0f3f3b8d5e.png)
[Niuke] b-complete square

资产安全问题或制约加密行业发展 风控+合规成为平台破局关键

字节P7专业级讲解:接口测试常用工具及测试方法,福利文

pytorch之数据类型tensor
![[Niuke] [noip2015] jumping stone](/img/9f/b48f3c504e511e79935a481b15045e.png)
[Niuke] [noip2015] jumping stone

系统休眠文件可以删除吗 系统休眠文件怎么删除
随机推荐
JTAG principle of arm bare board debugging
「精致店主理人」青年创业孵化营·首期顺德场圆满结束!
Neon Optimization: summary of performance optimization experience
golang中的WaitGroup实现原理
Failed to successfully launch or connect to a child MSBuild. exe process. Verify that the MSBuild. exe
[case sharing] basic function configuration of network loop detection
[JS] obtain the N days before and after the current time or the n months before and after the current time (hour, minute, second, year, month, day)
让我们,从头到尾,通透网络I/O模型
力扣1037. 有效的回旋镖
Installation and testing of pyflink
实现mysql与ES的增量数据同步
Gazebo的安装&与ROS的连接
UI控件Telerik UI for WinForms新主题——VS2022启发式主题
Neon Optimization: performance optimization FAQ QA
城联优品入股浩柏国际进军国际资本市场,已完成第一步
[100 cases of JVM tuning practice] 04 - Method area tuning practice (Part 1)
Dell笔记本周期性闪屏故障
省市区三级坐标边界数据csv转JSON
736. Lisp 语法解析 : DFS 模拟题
Let's see through the network i/o model from beginning to end