当前位置:网站首页>分享一个通用的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 %通配符,猜也能猜个差不多
$< 所有依赖
$* 所有目标%之前的部分。
边栏推荐
- Anfulai embedded weekly report no. 272: 2022.06.27--2022.07.03
- 重上吹麻滩——段芝堂创始人翟立冬游记
- Can the system hibernation file be deleted? How to delete the system hibernation file
- A brief history of deep learning (II)
- [100 cases of JVM tuning practice] 05 - Method area tuning practice (Part 2)
- Cause of handler memory leak
- Atomic in golang and CAS operations
- How do novices get started and learn PostgreSQL?
- UI control telerik UI for WinForms new theme - vs2022 heuristic theme
- MySQL script batch queries all tables containing specified field types in the database
猜你喜欢
[HFCTF2020]BabyUpload session解析引擎
阿里云中mysql数据库被攻击了,最终数据找回来了
重上吹麻滩——段芝堂创始人翟立冬游记
Building a dream in the digital era, the Xi'an station of the city chain science and Technology Strategy Summit ended smoothly
ClickHouse字段分组聚合、按照任意时间段粒度查询SQL
Batch obtain the latitude coordinates of all administrative regions in China (to the county level)
[hfctf2020]babyupload session parsing engine
Make a simple graphical interface with Tkinter
"Exquisite store manager" youth entrepreneurship incubation camp - the first phase of Shunde market has been successfully completed!
「精致店主理人」青年创业孵化营·首期顺德场圆满结束!
随机推荐
HMM 笔记
Part VI, STM32 pulse width modulation (PWM) programming
Analysis of mutex principle in golang
docker 方法安装mysql
[100 cases of JVM tuning practice] 04 - Method area tuning practice (Part 1)
斗地主游戏的案例开发
Taro2.* 小程序配置分享微信朋友圈
Fastdfs data migration operation record
Body mass index program, entry to write dead applet project
[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)
Installation of torch and torch vision in pytorch
Neon Optimization: summary of performance optimization experience
[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
UI控件Telerik UI for WinForms新主题——VS2022启发式主题
Your cache folder contains root-owned files, due to a bug in npm ERR! previous versions of npm which
736. Lisp 语法解析 : DFS 模拟题
ARM裸板调试之JTAG调试体验
第三方跳转网站 出现 405 Method Not Allowed
「笔记」折半搜索(Meet in the Middle)
Meet in the middle