module开发工程目录
来源:互联网 发布:怎么seo 编辑:程序博客网 时间:2024/06/05 08:33
1、目录组织结构如下,本文主要讨论几个问题:不同模块之间如何相互调用;如何使用多个源文件生成一个ko文件;采用多个子目录
2、模块通过EXPORT_SYMBOL导出函数,供其他模块使用.hello_.c
#include <linux/init.h>#include <linux/module.h>#include "common.h"static int hello_init(void){printk(KERN_ALERT "Hello ,modules world!\n");lib1();return 0;}static void hello_exit(void){printk(KERN_ALERT "Goodby,cruel world\n");}void func(void){printk("This is func\n");}MODULE_LICENSE("Dual BSD/GPL");module_init(hello_init);module_exit(hello_exit);EXPORT_SYMBOL(func);然后在hello2.c中就可以直接使用了:
#include <linux/init.h>#include <linux/module.h>#include <linux/kernel.h>//This function is define in module hellovoid func(void);int __init hello_init(void){printk("hello 2 !\n");func();return 0;}void __exit hello_exit(void){printk("hello 2 exit\n");}module_init(hello_init);module_exit(hello_exit);MODULE_LICENSE("Dual BSD/GPL");3、使用多个源文件生成一个ko文件,详细参照Kbuild文档:
obj-m := hello.o#This will link hello_.o and common.o to hello.kohello-objs += hello_.o common.o
4、项目主(根)目录下的Makefile改为:
obj-m += hello/obj-m += hello2/obj-m += hello3/make时将自动执行hello/目录下的Makefile文件
5、尝试在多处EXPORT_SYMBOL同一函数:在hello3.c中又定义一个名为func的函数,并导出:
echo "Kernel version: `uname -r`"Kernel version: 3.13.0-24-genericecho "kernel sources: "/lib/modules/`uname -r`/build""kernel sources: /lib/modules/3.13.0-24-generic/buildmake -C "/lib/modules/`uname -r`/build" SUBDIRS=`pwd` modulesmake[1]: Entering directory `/usr/src/linux-headers-3.13.0-24-generic' CC [M] /home/zhijian/work/fs/module_test/hello/hello_.o CC [M] /home/zhijian/work/fs/module_test/hello/common.o LD [M] /home/zhijian/work/fs/module_test/hello/hello.o CC [M] /home/zhijian/work/fs/module_test/hello2/hello2.o CC [M] /home/zhijian/work/fs/module_test/hello3/hello3.o Building modules, stage 2. MODPOST 3 modulesWARNING: /home/zhijian/work/fs/module_test/hello3/hello3: 'func' exported twice. Previous export was in /home/zhijian/work/fs/module_test/hello/hello.ko CC /home/zhijian/work/fs/module_test/hello/hello.mod.o LD [M] /home/zhijian/work/fs/module_test/hello/hello.ko CC /home/zhijian/work/fs/module_test/hello2/hello2.mod.o LD [M] /home/zhijian/work/fs/module_test/hello2/hello2.ko CC /home/zhijian/work/fs/module_test/hello3/hello3.mod.o LD [M] /home/zhijian/work/fs/module_test/hello3/hello3.komake[1]: Leaving directory `/usr/src/linux-headers-3.13.0-24-generic'得到警告 'func'exported twice。
0 0
- module开发工程目录
- Android开发--工程目录
- android studio工程目录同一文件夹下管理Module
- android开发工程下资源目录含义
- Android开发(3)----工程目录结构简介
- Android开发二:工程目录结构详解
- Android开发工程目录结构简介
- 目录工程
- 工程目录
- 工程目录
- 探索应用开发的基础之android工程目录结构
- android开发笔记——android工程目录结构:
- 导入工程(Module)与移除工程
- Flex Module 模块化开发
- nginx module开发helloworld
- Maven多Module开发
- android应用开发框架+即时通讯IM app开发(1)-前言和工程目录结构
- lead21工程目录框架
- css 浮动
- 使用tolua++编译pkg,从而创建自定义类让Lua脚本使用
- Android里针对ListView中选项进行排序的方法
- 2014 Multi-University Training Contest 6——by BUPT
- URAL1009 - K-based Numbers - 数位dp
- module开发工程目录
- 用Windows引导器启动Grub
- 无向连通图的割点和桥
- 【设计模式】----桥接模式
- request.getparameter和 request.getattribute的区别
- HDOJ 4925 Apple Tree
- tiny 210 烧录 根文件系统rootfs_qtopia_qt4.img 时 出现大量坏块,烧录不成功
- 从测试人员的角度思考应用的安全
- Unity依赖注入使用详解