linux编程出错

来源:百度知道 编辑:UC知道 时间:2024/05/22 05:25:03
这是程序:
#include <linux/kernel>
#include <linux/module>
#if CONFIG_MODVERSIONS
#define MODVERSIONS
#include <linux/modversions.h>
#endif

int init_module()
{
printk("Hello ,world this is the kernel speaking\n");
return 0;
}

void cleanup()
{
printk("short is the file of a kernel module\n");
}

编译:gcc -O -c -Wall hello.c
出错:hello.c:In function 'init_module':
hello.c:23:warning: implicit declaration of function 'printk'
用的就是kernel.h 问一下,这个和内核编译有没有关系的

貌似 header 没有引用正确?

你试试 include 那个 kernel.h 而不是直接 kernel 试试
--------------
刚注意,这个提示是 warning ,是一个提示,不是错误……
你说错误我也没看这行前面……