android 如何添加第3方lib库到kernel中
发布日期:2021-06-30 21:49:41 浏览次数:2 分类:技术文章

本文共 1178 字,大约阅读时间需要 3 分钟。

注意:只能将lib库放在kernel编译到的地方,如下:

alps/kernel/

alps/mediatek/custom/common/kernel/

alps/mediatek/custom/$platform/kernel/

alps/mediatek/custom/$proj/kernel/

alps/mediatek/kernel/

alps/mediatek/platform/$platform/kernel/core/

alps/mediatek/platform/$platform/kernel/drivers/

假设第3方库名称为test.a

(1). 如果存放的目录存在Makefile,那么只需在该Makefile最后添加:

obj-y += test.a

然后将test.a文件复制到该目录下,

重新命名为test.a_shipped,目的是防止clean kernel阶段把该库给清除掉!

重新编译kernel即可。

(2). 如果存放的目录不存在Makefile,比如在alps/mediatek/custom/目录下的kernel目录都没有Makefile,这时需要自行添加一个Makefile,内容和第1种方法差不多:

obj-y := xxx.o yyy.o test.a

以上表示将xxx.c/yyy.c和test.a编译到kernel

然后将test.a文件复制到该目录下并重新命名为test.a_shipped

重新编译kernel即可。

注意:alps/mediatek/custom/common/kernel/touchpanel/xxx目录下的文件会和alps/mediatek/custom/common/kernel/touchpanel/src目录合并,obj-y要将两个目录下的obj全部加入才行,否则编译失败。也可以用以下Makefile,自动将所有obj加入obj-y,省却麻烦。其他目录如有类似的情形一样处理。

添加的Makefile(将所有*.c变为*.o并加入obj-y):

include $(MTK_PATH_BUILD)/common.mk

path := $(if $(filter yes,$(KBUILD_OUTPUT_SUPPORT)),$(srctree)/$(obj),$(obj))

obj-y := $(patsubst %.c,%.o,$(subst $(path)/,,$(call wildcard2,$(path)/*.c)))

obj-y += test.a


说明:对于kernel的Makefile编写规则说明,可以到网络搜索相关材料参考,比如obj-y表示要编译到kernel,而obj-m表示要编译成module,obj-n或obj-表示不编译

转载地址:https://loongembedded.blog.csdn.net/article/details/41011079 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:技术负责人的三种角色
下一篇:如何搭建modem编译环境

发表评论

最新留言

关注你微信了!
[***.104.42.241]2024年04月11日 16时30分34秒