zhougy 发表于 2004-1-29 17:25:20

怎么编译2.6.1内核的模块???

刚刚编译了新内核2.6.1和新的insmod等工具

将2.6.1内核include下的asm asm-general linux 复制到/usr/include下

有如下程序hello.c:

    #include <linux/init.h>
    #include <linux/module.h>
    #include <linux/kernel.h>

    static int hello_init(void)
    {
      printk(KERN_ALERT "Hello, world\n");
      return 0;
    }

    static void hello_exit(void)
    {
      printk(KERN_ALERT "Goodbye, cruel world\n");
    }

    module_init(hello_init);
    module_exit(hello_exit);


使用命令 gcc -c hello.c编译出现了下面一堆错误(下面的只是一部分)!


/usr/include/linux/module.h: In function `try_module_get':
/usr/include/linux/module.h:307: error: invalid type argument of `->'
/usr/include/linux/module.h:312: error: invalid type argument of `->'
/usr/include/linux/module.h:312: error: `TIF_NEED_RESCHED' undeclared (first use in this function)
/usr/include/linux/module.h: In function `module_put':
/usr/include/linux/module.h:320: error: invalid type argument of `->'
/usr/include/linux/module.h:325: error: invalid type argument of `->'
/usr/include/linux/module.h:325: error: `TIF_NEED_RESCHED' undeclared (first use in this function)
/usr/include/linux/module.h: In function `MOD_INC_USE_COUNT':
/usr/include/linux/module.h:483: error: `KERN_WARNING' undeclared (first use in
this function)
/usr/include/linux/module.h:483: error: parse error before string constant
/usr/include/linux/module.h:486: error: invalid type argument of `->'
/usr/include/linux/module.h:487: error: invalid type argument of `->'
/usr/include/linux/module.h:487: error: `TIF_NEED_RESCHED' undeclared (first use in this function)

请问我是那个地方出错了???该如何解决????多谢了!!!!

Dragonfly 发表于 2004-1-30 00:11:23

why did this? "将2.6.1内核include下的asm asm-general linux 复制到/usr/include下 "

check this. http://crab.ele.uri.edu/tmp/chdev_kstat.tgz i wrote this for iometer, pretty simple to understand.

read INSTALL first.
:-D:-D

zhougy 发表于 2004-1-30 12:10:09

多谢斑竹 受益非浅阿!!!

Dragonfly 发表于 2004-2-1 10:58:26

welcome.
:-D:-D:-D
页: [1]
查看完整版本: 怎么编译2.6.1内核的模块???