当前位置:网站首页>分享一个通用的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 %通配符,猜也能猜个差不多
$< 所有依赖
$* 所有目标%之前的部分。
边栏推荐
- "Exquisite store manager" youth entrepreneurship incubation camp - the first phase of Shunde market has been successfully completed!
- 批量获取中国所有行政区域经边界纬度坐标(到县区级别)
- [batch dos-cmd command - summary and summary] - jump, cycle, condition commands (goto, errorlevel, if, for [read, segment, extract string]), CMD command error summary, CMD error
- Gazebo的安装&与ROS的连接
- [HFCTF2020]BabyUpload session解析引擎
- Taro2.* 小程序配置分享微信朋友圈
- ARM裸板调试之JTAG调试体验
- Rainstorm effect in levels - ue5
- 资产安全问题或制约加密行业发展 风控+合规成为平台破局关键
- Telerik UI 2022 R2 SP1 Retail-Not Crack
猜你喜欢
Lldp compatible CDP function configuration
Part VI, STM32 pulse width modulation (PWM) programming
让我们,从头到尾,通透网络I/O模型
Dell筆記本周期性閃屏故障
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
Dell Notebook Periodic Flash Screen Fault
[hfctf2020]babyupload session parsing engine
Activereportsjs 3.1 Chinese version | | | activereportsjs 3.1 English version
Analysis of mutex principle in golang
c语言—数组
随机推荐
docker 方法安装mysql
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
自旋与sleep的区别
Supersocket 1.6 creates a simple socket server with message length in the header
ESP Arduino (IV) PWM waveform control output
[100 cases of JVM tuning practice] 05 - Method area tuning practice (Part 2)
Let's talk about 15 data source websites I often use
Niuke cold training camp 6B (Freund has no green name level)
A brief history of deep learning (II)
Atomic in golang, and cas Operations
c语言—数组
「笔记」折半搜索(Meet in the Middle)
Rainstorm effect in levels - ue5
ClickHouse字段分组聚合、按照任意时间段粒度查询SQL
pyflink的安装和测试
Your cache folder contains root-owned files, due to a bug in npm ERR! previous versions of npm which
Can the system hibernation file be deleted? How to delete the system hibernation file
from . cv2 import * ImportError: libGL. so. 1: cannot open shared object file: No such file or direc
系统休眠文件可以删除吗 系统休眠文件怎么删除
城联优品入股浩柏国际进军国际资本市场,已完成第一步