empty variable name
来源:互联网 发布:倩女幽魂大盗宝藏算法 编辑:程序博客网 时间:2024/06/01 07:59
今天在编写一个最简单的hello驱动,在make的时候出现了“empty variable name”,
最后是如下原因:在Makefile中有如下一句话,出现这个错误的原因是“=”左边多了一个空格
make -C $(LINUX_SRC) SUBDIRS=$(shell pwd) modules
如果在"="右边多一个空格,则会出现另外的错误:
*** Error during update of the kernel configuration.
make[3]: *** [silentoldconfig] Error 1
make[2]: *** [silentoldconfig] Error 2
make[1]: Nothing to be done for `/home/chen/hello_module'.
make[1]: *** No rule to make target `include/config/auto.conf', needed by `include/config/kernel.release'. Stop.
make[1]: Leaving directory `/usr/src/linux-headers-2.6.35-22-generic'
make: *** [all] Error 2
最后的源码hello.c源码:
/*hello_module.c*/
#include "linux/module.h"
#include "linux/init.h"
MODULE_LICENSE("Dual BSD/GPL");
static int __init hello_init(void)
{
printk(KERN_ALERT "Hello, world\n");
return 0;
}
static void __exit hello_exit(void)
{
printk(KERN_ALERT "Goodbye, cruel world\n");
}
module_init(hello_init);
module_exit(hello_exit);
关于hello.c的一点解释:
module_init(hello_init)指定在初始化的时候执行的函数,
module_exit(hello_exit)指定在卸载驱动的时候执行的函数;
另外这里用的是printk问不是printf,这时因为Linux内核不需要标准C库和其他函数库的支持,printk是内核的打印函数;
KERN_ALERT表示打印字符串的优先等级,该等级表示需要立即执行的情况;
Makefile的源码:
LINUX_SRC =/lib/modules/$(shell uname -r)/build
obj-m := hello.o
all:
make -C $(LINUX_SRC) SUBDIRS=$(shell pwd) modules
clean:
rm -rf *.cmd *.d *.ko *.mod.c *.symvers *.order *.o
效果:
在make生成hello.ko之后执行:insmod ./helloworld.ko
这时看不到任何输出,如果再运行 insmod hello.ko还会出现
insmod: error inserting './helloworld.ko': -1 File exists
这时因为你重复载入模块
用命令 lsmod 可以看到系统里已经有哦这个模块了
重新开一个终端(称为B,原来的终端称为A)
在终端B中,用命令执行cat /proc/kmsg
然后再回到终端A中执行 insmod hello.ko和rmmod hello.ko,便可以在终端B上看到输出(如果提示上述红色标志的错误,请先执行rmmod hello.ko),
也可以在终端B中执行下面两个命令,这时可以看到以前的输出内容
tail /var/log/syslog或cat /var/log/syslog
如果系统一直打印,可以按Ctrl-C手动终止
转自:http://blog.csdn.net/qingtingchen1987/article/details/7029910
- empty variable name
- empty variable name
- Name cannot be empty.
- name&variable scope
- tensorflow:name&variable scope
- Variable references empty selection: ${project_loc}解决方法
- Variable references empty selection: ${project_loc}的解决办法
- PHP's numeric variable name...
- Automake stops with “non-POSIX variable name”
- ORA-01036: illegal variable name/number
- Extjs 常见错误 SyntaxError: missing variable name
- ora-01036 illegal variable name number
- Linux - Rules for Naming variable name
- ORA-01036: illegal variable name/number
- extern type variable name问题及解决方案
- instance variable 'name' accessed in class method
- tensorflow学习笔记(十七):name&variable scope
- Firebug常见错误:SyntaxError:missing variable name
- 亲密接触gentoo之设置locale
- Struts2框架(七)
- 一个奋斗着的菜鸟
- linux 操作系统学习 第一课 基本命令处理
- SVN常用命令
- empty variable name
- Windows界面编程第五篇 静态控件背景透明化
- OpenCL学习博客
- 2013年01月05日 工作总结
- 程序员如何保持优秀
- keep avlie tomcat设置
- 你读得太多了
- uboot源代码分析及移植
- 最有价值的编程忠告(来自贝尔实验室Plan 9操作系统的创始人Rob Pike)