当前位置:网站首页>分享一个通用的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 %通配符,猜也能猜个差不多
$< 所有依赖
$* 所有目标%之前的部分。
边栏推荐
- Mongodb client operation (mongorepository)
- NEON优化:关于交叉存取与反向交叉存取
- Grc: personal information protection law, personal privacy, corporate risk compliance governance
- from .cv2 import * ImportError: libGL.so.1: cannot open shared object file: No such file or direc
- docker 方法安装mysql
- Transformation transformation operator
- 让我们,从头到尾,通透网络I/O模型
- from . cv2 import * ImportError: libGL. so. 1: cannot open shared object file: No such file or direc
- In rails, when the resource creation operation fails and render: new is called, why must the URL be changed to the index URL of the resource?
- windows安装mysql8(5分钟)
猜你喜欢

Niuke cold training camp 6B (Freund has no green name level)

Make a simple graphical interface with Tkinter

UI control telerik UI for WinForms new theme - vs2022 heuristic theme

如何管理分布式团队?

Dell筆記本周期性閃屏故障

windows安装mysql8(5分钟)

"Exquisite store manager" youth entrepreneurship incubation camp - the first phase of Shunde market has been successfully completed!

View remote test data and records anytime, anywhere -- ipehub2 and ipemotion app

LLDP兼容CDP功能配置

微信公众号发送模板消息
随机推荐
Neon Optimization: About Cross access and reverse cross access
The printf function is realized through the serial port, and the serial port data reception is realized by interrupt
筑梦数字时代,城链科技战略峰会西安站顺利落幕
from .cv2 import * ImportError: libGL.so.1: cannot open shared object file: No such file or direc
UI control telerik UI for WinForms new theme - vs2022 heuristic theme
"Exquisite store manager" youth entrepreneurship incubation camp - the first phase of Shunde market has been successfully completed!
Gazebo的安装&与ROS的连接
微信公众号发送模板消息
第三方跳转网站 出现 405 Method Not Allowed
【案例分享】网络环路检测基本功能配置
Force buckle 1037 Effective boomerang
动态规划思想《从入门到放弃》
[batch dos-cmd command - summary and summary] - string search, search, and filter commands (find, findstr), and the difference and discrimination between find and findstr
Informatics Olympiad YBT 1171: factors of large integers | 1.6 13: factors of large integers
go-zero微服务实战系列(九、极致优化秒杀性能)
系统休眠文件可以删除吗 系统休眠文件怎么删除
How do novices get started and learn PostgreSQL?
「笔记」折半搜索(Meet in the Middle)
pytorch之数据类型tensor
from . cv2 import * ImportError: libGL. so. 1: cannot open shared object file: No such file or direc