用cygwin编译内核模块的问题,急,在线等待!!
我在cygwin下用strong arm的交叉编译器编译下面的一个超简单的模块,结果问题多多。
/*hello.c*/
#include <linux/kernel.h> /* We’re doing kernel work */
#include <linux/module.h> /* Specifically, a module */
/* Deal with CONFIG_MODVERSIONS */
/*
#if CONFIG_MODVERSIONS==1
#define MODVERSIONS
#include <linux/modversions.h>
#endif
*/
/* Initialize the module */
int init_module()
{
printk("Hello, world - this is the kernel speaking\n");
return 0;
}
void cleanup_module()
{
printk("Short is the life of a kernel module\n");
}
当我直接用cygwin的linux内核时,即如下的makefile
/*makefile*/
CC=arm-linux-gcc
LDFLAGS=-Xlinker -rpath-link /usr/local/lib/gcc-lib/arm-linux/2.95.2-6
LFLAGS-Wall -DMODULE -D__KERNEL__ -DLINUX
all: hello.o
hello.o: hello.c /usr/src/linux-2.4.19/include/linux/version.h
$(CC) hello.c $(LFLAGS) -c
没有什么错误,提示如下:
/cygdrive/c/DOCUME~1/ADMINI~1/LOCALS~1/Temp/ccm0CEMS.s: Assembler messages:
/cygdrive/c/DOCUME~1/ADMINI~1/LOCALS~1/Temp/ccm0CEMS.s:6: Warning: Ignoring changed section attributes for .modinfo
当我加上-I参数用新的内核编译的时候,即如下makefile
/*makefile*/
CC=arm-linux-gcc
LDFLAGS=-Xlinker -rpath-link /usr/local/lib/gcc-lib/arm-linux/2.95.2-6
LFLAGS=-I/usr/src/linux-2.4.19-sa1110/include -Wall -DMODULE -D__KERNEL__ -DLINUX
all: hello.o
hello.o: hello.c /usr/src/linux-2.4.19/include/linux/version.h
$(CC) hello.c $(LFLAGS) -c
出现如下错误:
In file included from /usr/src/linux-2.4.19-sa1110/include/linux/prefetch.h:13,
from /usr/src/linux-2.4.19-sa1110/include/linux/list.h:6,
from /usr/src/linux-2.4.19-sa1110/include/linux/module.h:12,
from hello.c:2:
/usr/src/linux-2.4.19-sa1110/include/asm/processor.h:50: warning: no semicolon a
t end of struct or union
/usr/src/linux-2.4.19-sa1110/include/asm/processor.h:50: parse error before `1'
/usr/src/linux-2.4.19-sa1110/include/asm/processor.h:52: parse error before `}'
/usr/src/linux-2.4.19-sa1110/include/asm/processor.h:56: field `insn' has incomp
lete type
make: *** [hello.o] Error 1
注:所用新的内核单独编译没有错误。
怎么办?
高手救我
3x very much!!