当前位置:网站首页>分享一个通用的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 %通配符,猜也能猜个差不多
$< 所有依赖
$* 所有目标%之前的部分。
边栏推荐
- Windows installation mysql8 (5 minutes)
- Address information parsing in one line of code
- 让我们,从头到尾,通透网络I/O模型
- Part IV: STM32 interrupt control programming
- Dell筆記本周期性閃屏故障
- 力扣1037. 有效的回旋镖
- ESP Arduino (IV) PWM waveform control output
- Return to blowing marshland -- travel notes of zhailidong, founder of duanzhitang
- ARM裸板调试之JTAG原理
- [100 cases of JVM tuning practice] 04 - Method area tuning practice (Part 1)
猜你喜欢
![[case sharing] basic function configuration of network loop detection](/img/d8/a367c26b51d9dbaf53bf4fe2a13917.png)
[case sharing] basic function configuration of network loop detection

Body mass index program, entry to write dead applet project

Data type of pytorch tensor
Summary of being a microservice R & D Engineer in the past year

Gazebo的安装&与ROS的连接

Your cache folder contains root-owned files, due to a bug in npm ERR! previous versions of npm which

城联优品入股浩柏国际进军国际资本市场,已完成第一步

Installation and testing of pyflink

The MySQL database in Alibaba cloud was attacked, and finally the data was found

2022 Google CTF SEGFAULT LABYRINTH wp
随机推荐
Let's talk about 15 data source websites I often use
Provincial and urban level three coordinate boundary data CSV to JSON
Explain in detail the matrix normalization function normalize() of OpenCV [norm or value range of the scoped matrix (normalization)], and attach norm_ Example code in the case of minmax
golang中的Mutex原理解析
The difference between spin and sleep
The printf function is realized through the serial port, and the serial port data reception is realized by interrupt
字节P7专业级讲解:接口测试常用工具及测试方法,福利文
Mongodb client operation (mongorepository)
tensorflow 1.14指定gpu运行设置
What kind of experience is it to realize real-time collaboration in jupyter
城联优品入股浩柏国际进军国际资本市场,已完成第一步
动态规划思想《从入门到放弃》
Segmenttree
[HFCTF2020]BabyUpload session解析引擎
Neon Optimization: About Cross access and reverse cross access
What are the differences between Oracle Linux and CentOS?
Data type of pytorch tensor
树莓派/arm设备上安装火狐Firefox浏览器
go-zero微服务实战系列(九、极致优化秒杀性能)
Cause of handler memory leak