日期:2014-05-16  浏览次数:20646 次

奇怪的问题-cann't find module.h
随便写了个helloworld的驱动模块如下:
//helloworld.c
#define   MODULE
include <Linux/module.h>    
int   init_module()    
{        
            printk( "   hello   world   !\n’);    

            return   1;  
  }    
int   cleanup_module()  
  {    
        printk( "   I   will   shut   down   myself   in   kernerl   mod   /n) ";    
        retutn   0;  
  }    
gcc   -c   helloworld.c
显示不能找到module.h那个目录或文件
强制把module.h头文件定位到
/usr/src/...中的module.h
显示了一堆找不到其它文件的信息。
我用的是FC6系统,gcc4.1.1.1版,内核2.6.18
望哪位大侠指点下!



------解决方案--------------------
应该不能这样编译吧。
ifneq ($(KERNELRELEASE),)
obj-m :=app.o
else
PWD :=$(shell pwd)
KVER ?=$(shell uname -r)
KDIR := /lib/modules/$(KVER)/build
all:
$(MAKE) -C $(KDIR) M=$(PWD)
endif
它其实需要调用kbuild来生成ko。

------解决方案--------------------
linux设备驱动开发群42013154
------解决方案--------------------
gcc -c helloworld.c????
那是编译应用程序的做法!!!!!
你没仔细看《Linux设备驱动》第三版
你到网上找到那本书的源码,里面有MAKEFILE的例子,你稍改一下就OK了