|
#include <linux/kernel.h>
#include <linux/module.h>
int init_module()
{
printk("Hello, world - this is the kernel speaking\n");
return 0;
}
void cleanup_module()
{
printk("Short is the life of a kernel module\n");
}
上述代码非常简单,但为什么会有下面的错误:
2.cpp:2:26: error: linux/module.h: No such file or directory
2.cpp: In function ‘int init_module()’:
2.cpp:6: error: ‘printk’ was not declared in this scope
2.cpp: In function ‘void cleanup_module()’:
2.cpp:14: error: ‘printk’ was not declared in this scope
是不是需要安装linux的内核的源代码?安装在哪?是在/usr/src/下码? |
|