MODPOST 1 modules/bin/sh: scripts/mod/modpost: not found的解决
来源:互联网 发布:靠谱网络危机公关公司 编辑:程序博客网 时间:2024/05/22 14:13
linux 2.6下编译最简单的hello.ko驱动
1.下载kernel源码 http://www.kernel.org/
2.配置内核
luther@gliethttp:~/work/kernel/linux-2.6.22.14$ make oldconfigluther
@gliethttp:~/work/kernel/linux-2.6.22.14$ make prepare
luther
@gliethttp:~/work/kernel/linux-2.6.22.14$ make scripts 否则提示:MODPOST 1 modules/bin/sh: scripts/mod/modpost: not found
3.写测试程序hello.c
//luther@gliethttp:~/work/kernel/module_drivers/hello$ vim hello.c
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
static int init_hello_4(void)
{
printk(KERN_ALERT "Hello, world 4 ");
return 0;
}
static void cleanup_hello_4(void)
{
printk(KERN_ALERT "Goodbye, world 4 ");
}
module_init(init_hello_4);
module_exit(cleanup_hello_4);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Playmud");
MODULE_DESCRIPTION("Test only!");
4.配置Makefile和执行ko编译luther
@gliethttp:~/work/kernel/module_drivers/hello$ echo "obj-m:=hello.o" > Makefile
luther
@gliethttp:~/work/kernel/module_drivers/hello$ make -C /usr/src/`uname -r` M=`pwd` modules
我下载的内核位置为~/work/kernel/linux-2.6.22.14,所以这里指定为:luther
@gliethttp:~/work/kernel/module_drivers/hello$ make -C ../../linux-2.6.22.14 M=`pwd` modules
make: Entering directory `/home/luther
/work/kernel/linux-2.6.22.14'
WARNING: Symbol version dump /home/luther/work/kernel/linux-2.6.22.14/Module.symvers
is missing; modules will have no dependencies and modversions.
Building modules, stage 2.
MODPOST 1 modules
CC /home/luther/work/kernel/module_drivers/hello/hello.mod.o
LD [M] /home/luther/work/kernel/module_drivers/hello/hello.ko
make: Leaving directory `/home/luther/work/kernel/linux-2.6.22.14'luther
@gliethttp:~/work/kernel/module_drivers/hello$
上面的做法当然是可以,但是老是提示:
WARNING: Symbol version dump /home/luhter/work/kernel/linux-2.6.22.14/Module.symvers is missing; modules will have no dependencies and modversions.
通过摸索,原来,编译hello.ko其实是非常简单的,不用下载kernel源码,写测试程序hello.c
//luther@gliethttp:~/work/kernel/module_drivers/hello$ vim hello.c
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
static int init_hello_4(void)
{
printk(KERN_ALERT "Hello, world 4 ");
return 0;
}
static void cleanup_hello_4(void)
{
printk(KERN_ALERT "Goodbye, world 4 ");
}
module_init(init_hello_4);
module_exit(cleanup_hello_4);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Playmud");
MODULE_DESCRIPTION("Test only!");
4.配置Makefile和执行ko编译
luther
@gliethttp:~/work/kernel/module_drivers/hello$ echo "obj-m:=hello.o" > Makefile
luther
@gliethttp:~/work/kernel/module_drivers/hello$ make -C /lib/modules/`uname -r`/build M=`pwd` modules
make: Entering directory `/usr/src/linux-headers-2.6.22-14-generic'
CC [M] /home/
luther
/work/kernel/module_drivers/hello/hello.o
Building modules, stage 2.
MODPOST 1 modules
CC /home/
luther
/work/kernel/module_drivers/hello/hello.mod.o
LD [M] /home/
luther
/work/kernel/module_drivers/hello/hello.ko
make: Leaving directory `/usr/src/linux-headers-2.6.22-14-generic'
luther
@gliethttp:~/work/kernel/module_drivers/hello$
/lib/modules/`uname -r`/build就是本地ubuntu机子的module编译配置目录
不是为正在运行的内核编译模块:make -C <path-to-kernel> M='pwd'
为正在运行的内核编译模块:
make -C /lib/modules/'uname -r'/build M='pwd'
不用下载kernel,直接就在本地机搞定了!
printk没有在console上打印出提示,通过
luther
@gliethttp:~/work/kernel/module_drivers/hello$ dmesg |tail
可以查到,具体配置可以查看
luther
@gliethttp:~/work/kernel/module_drivers/hello$ vim /etc/syslog.conf
- MODPOST 1 modules/bin/sh: scripts/mod/modpost: not found的解决
- 驱动编译错误 /bin/sh: scripts/mod/modpost
- scripts/mod/modpost
- MODPOST 0 modules的解决办法
- WARNING: modpost: Found 1 section mismatch(es).
- 关于无法生成模块的原因MODPOST 0 modules
- HOSTCC scripts/basic/fixdep /bin/sh: line 1: gcc: command not found解决办法
- bin.sh not found
- 解决编译kernel出现WARNING: modpost: Found 4 section mismatch(es)
- 编译错误: /bin/sh: 1: pushd: not found的问题
- 编译错误: /bin/sh: 1: pushd: not found的问题
- 编译错误: /bin/sh: 1: pushd: not found的问题
- bin/sh: hello :not found 的解决方法
- -/bin/sh: 命令:not found的解决办法
- -/bin/sh: 命令:not found的解决办法
- ubuntu下hello world kernel Module:MODPOST 0 modules
- /bin/sh: 1: mysql_config: not found
- 错误:/bin/sh: 1: protoc: not found
- 结构异常和C++异常
- 测试
- 函数指针 用法
- struts2学习(7)struts2中的带参数的结果集
- EXT+formpanel+之+table+布局+并且显示+fieldlabel
- MODPOST 1 modules/bin/sh: scripts/mod/modpost: not found的解决
- dos命令删除目录下的子目录及文件
- 总结几种常见的Word转换PDF方法
- java基本类型的对象类型在集合的判断
- 虚函数表
- 游戏对象的实现 (补)
- NHibernate 3.2.0-GA Breaking Changes
- Directory Listing Denied
- atoi() 与 itoa()函数的内部实现