简单的hello world module,不知道如何一直编译出错,多谢

简单的hello world module,不知道如何一直编译出错,多谢

简单的hello world module,不知道怎么一直编译出错,谢谢
刚学写驱动,编译hello     world时出问题了,请问一下有什么问题,谢谢,我不知道是不是应该把hello.c放在include文件夹下。。。
[root@localhost     include]#     gcc     -O2     -DMODULE     -D__MODULE__     -c     hello.c
hello.c:1:23:     错误:linux/init.h:没有那个文件或目录
hello.c:2:25:     错误:linux/module.h:没有那个文件或目录
hello.c:3:     错误:expected     declaration     specifiers     or     ‘…’     before     string     constant
hello.c:3:     警告:数据定义时没有类型或存储类
hello.c:     在函数     ‘hello_init’     中:
hello.c:7:     错误:‘KERN_ALERT’     未声明     (在此函数内第一次使用)
hello.c:7:     错误:(即使在一个函数内多次出现,每个未声明的标识符在其
hello.c:7:     错误:所在的函数内只报告一次。)
hello.c:7:     错误:expected     ‘)’     before     string     constant
hello.c:     在函数     ‘hello_exit’     中:
hello.c:14:     错误:‘KERN_ALERT’     未声明     (在此函数内第一次使用)
hello.c:14:     错误:expected     ‘)’     before     string     constant
hello.c:     在顶层:
hello.c:17:     警告:数据定义时没有类型或存储类
hello.c:17:     警告:函数声明中出现形参名却未指定类型
hello.c:18:     警告:数据定义时没有类型或存储类
hello.c:18:     警告:函数声明中出现形参名却未指定类型  
        1   #include <linux/init.h>
            2   #include <linux/module.h>
            3   MODULE_LICENSE( "Dual   BSD/GPL ");
            4  
            5   static     int   hello_init(void)
            6   {
            7           printk(KERN_ALERT   "Hello,worldn ");
            8  
            9           return   0;
          10   }
          11  
          12   static     void         hello_exit(void)
          13   {
          14           printk(KERN_ALERT   "Goodbye,cuel   worldn ");
          15   }
          16  
          17   module_init(hello_init);
          18   module_exit(hello_exit);


接分


gcc -D__KERNEL__ -DMODULE -DLINUX -I /usr/local/src/linux2.4/include -c -O1

简单的hello world module,不知道如何一直编译出错,多谢

相关文章:

你感兴趣的文章:

标签云: