LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 955|回复: 7

我的模块为什么不能编译?

[复制链接]
发表于 2004-5-27 11:44:05 | 显示全部楼层 |阅读模式
我按照书上编写了一个简单的模块例子:hello.c

  1. #define MODULE
  2. #include <linux/module.h>

  3. int init_module(void)
  4. {
  5. printk("<1> hello world!\n");
  6. return 0;
  7. }

  8. void cleanup_module(void)
  9. {
  10. printk("<1> goodbye!\n");
  11. }
复制代码

很简单也比较傻,可是我用
gcc -c hello.c
编译时,却通过不了:
in file included from /usr/include/linux/module.h:10,
                 from hello.c:2
/usr/include/linux/config.h:4:28 linux/autoconf.h: no such file or directory
…………………………………………………………
请问这是怎么回事呢?
:thank
 楼主| 发表于 2004-5-27 17:30:08 | 显示全部楼层

自己顶!

我顶!
发表于 2004-5-27 21:02:35 | 显示全部楼层
#define MODULE
#include <linux/module.h>

int init_module(void)
{
        printk("<1> Hello World\n");
        return 0;
}

void cleanup_module(void)
{
        printk("<1> Bye,Bye\n");
}


gcc -c helloword.c -I /usr/src/linux-2.4.20/include
 楼主| 发表于 2004-5-28 18:20:24 | 显示全部楼层

谢谢了,但是问题还是没有解决

我按照你的方法做了,但是还是没有解决:(
出现的问题是一样的
发表于 2004-5-31 10:58:40 | 显示全部楼层
加上#define __KERNEL__ 再试试
 楼主| 发表于 2004-5-31 11:38:33 | 显示全部楼层

:(还是不行

不知道为什么
谢谢了先
发表于 2004-6-2 09:14:06 | 显示全部楼层
前面
# include <linux/module.h>
# include <linux/kernel.h>
不要#define MODULE

gcc -c -Wall -D__KERNEL__ -DMODULE -I/usr/src/linux-2.4/include helloworld.c
 楼主| 发表于 2004-6-7 09:43:42 | 显示全部楼层

还是不行:(

不如兄弟给一个可行的例子吧。
谢谢了
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表