哪位高手能帮小弟我编译通过2行代码<linux/module.h>小弟我给100分

哪位高手能帮小弟我编译通过2行代码<linux/module.h>小弟我给100分

谁能帮我编译通过2行代码<linux/module.h>,我给100分
一个简单的代码:
//hello.c
#include   <linux/kernel.h>
#include   <linux/module.h>

#ifdef   MODEVERSIONS
#include   <linux/modeversions.h>
#endif

int   init_module()
{
printk( "new   module   init… ");
return   1;
}

int   cleanup_module()
{
printk( "module   is   removed ");
return   0;
}

[root@linux   usr]#   gcc   -o   test_app   hello.c  
hello.c:2:26:   错误:linux/module.h:没有那个文件或目录

[root@linux   usr]#   gcc   -o   test_app   hello.c   -I/usr/src/f6-2.6.18/include/

In   file   included   from   /usr/src/f6-2.6.18/include/linux/bitops.h:9,
                                  from   /usr/src/f6-2.6.18/include/linux/thread_info.h:20,
                                  from   /usr/src/f6-2.6.18/include/linux/preempt.h:9,
                                  from   /usr/src/f6-2.6.18/include/linux/spinlock.h:49,
                                  from   /usr/src/f6-2.6.18/include/linux/module.h:10,
                                  from   hello.c:2:
/usr/src/f6-2.6.18/include/asm/bitops.h:244:   错误:expected   ‘=’,   ‘,’,   ‘;’,   ‘asm’   or   ‘__attribute__’   before   ‘int’
In   file   included   from   /usr/src/f6-2.6.18/include/linux/spinlock.h:56,
                                  from   /usr/src/f6-2.6.18/include/linux/module.h:10,
                                  from   hello.c:2:
/usr/src/f6-2.6.18/include/asm/system.h:306:   错误:expected   declaration   specifiers   or   ‘…’   before   ‘u8’
/usr/src/f6-2.6.18/include/asm/system.h:306:   错误:expected   declaration   specifiers   or   ‘…’   before   ‘u8’
/usr/src/f6-2.6.18/include/asm/system.h:307:   错误:expected   declaration   specifiers   or   ‘…’   before   ‘u16’
/usr/src/f6-2.6.18/include/asm/system.h:307:   错误:expected   declaration   specifiers   or   ‘…’   before   ‘u16’
/usr/src/f6-2.6.18/include/asm/system.h:308:   错误:expected   declaration   specifiers   or   ‘…’   before   ‘u32’
/usr/src/f6-2.6.18/include/asm/system.h:308:   错误:expected   declaration   specifiers   or   ‘…’   before   ‘u32’
/usr/src/f6-2.6.18/include/asm/system.h:   在函数   ‘cmpxchg_386’   中:


不是用gcc直接编译,需要写在Makefile内然后编译。
#Makefile
obj-m += helloworld.o

#make -C /usr/src/kernel/`uname -r`-i686 SUBDIRS=$PWD modules


hello.c代码
/*******************************

哪位高手能帮小弟我编译通过2行代码<linux/module.h>小弟我给100分

相关文章:

你感兴趣的文章:

标签云: