当前位置: 技术问答>linux和unix
linux设备管理实验--写的一个驱动程序
来源: 互联网 发布时间:2016-07-23
本文导语: 以下错误,初学看不懂,大虾帮忙看看啊, 在VM下运行的RedHat linux9.0(文件名cao2.c) 用#gcc -D__KERNEL__ -DMODULE -O2 -g -Wall -c cao2.c编译 In file include from/usr/include/linux/fs.h:23, from/usr/include/linux/devfs...
以下错误,初学看不懂,大虾帮忙看看啊, 在VM下运行的RedHat linux9.0(文件名cao2.c)
用#gcc -D__KERNEL__ -DMODULE -O2 -g -Wall -c cao2.c编译
In file include from/usr/include/linux/fs.h:23,
from/usr/include/linux/devfs_kernel.h:4,
from cao2.c:4:
/usr/include/linux/string.h:8:2 waring:#waring Using kernel header in userland!
In file include from/usr/include/linux/sched.h:14,
from/usr/include/linux/mm.h:4,
from/usr/include/linux/locks.h:5,
from/usr/include/linux/devfs_fs_kernel.h:6,
from cao2.c:4:
/usr/include/linux/timex.h:173:field 'time' has incomplete type
/usr/include/linux/timex.h:188:confused by esrlier errors,bailing out
用#gcc -D__KERNEL__ -DMODULE -O2 -g -Wall -c cao2.c编译
In file include from/usr/include/linux/fs.h:23,
from/usr/include/linux/devfs_kernel.h:4,
from cao2.c:4:
/usr/include/linux/string.h:8:2 waring:#waring Using kernel header in userland!
In file include from/usr/include/linux/sched.h:14,
from/usr/include/linux/mm.h:4,
from/usr/include/linux/locks.h:5,
from/usr/include/linux/devfs_fs_kernel.h:6,
from cao2.c:4:
/usr/include/linux/timex.h:173:field 'time' has incomplete type
/usr/include/linux/timex.h:188:confused by esrlier errors,bailing out
|
ifneq ($(KERNELRELEASE),)
obj-m :=cao2.o
else
KDIR :=/lib/modules/$(shell uname -r)/build
PWD :=$(shell pwd)
default:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
rm -r -f .tmp_versions *.mod.c .*.cmd *.o Modules.symvers
endif
保存为Makefile
然后
make
obj-m :=cao2.o
else
KDIR :=/lib/modules/$(shell uname -r)/build
PWD :=$(shell pwd)
default:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
rm -r -f .tmp_versions *.mod.c .*.cmd *.o Modules.symvers
endif
保存为Makefile
然后
make
|
注意你的makefile版本要是2.4内核用的
Makefile的tab相关格式注意没
|
对照LDD的书(有例子),肯定能解决问题的。
2.4的对照ldd2
2.6的对照ldd3
2.4的对照ldd2
2.6的对照ldd3