当前位置: 技术问答>linux和unix
用cygwin编译内核模块的问题,急,在线等待!!
来源: 互联网 发布时间:2015-06-26
本文导语: 我在cygwin下用strong arm的交叉编译器编译下面的一个超简单的模块,结果问题多多。 /*hello.c*/ #include /* We’re doing kernel work */ #include /* Specifically, a module */ /* Deal with CONFIG_MODVERSIONS */ /* #if CONFIG_MODVERSIONS==1...
我在cygwin下用strong arm的交叉编译器编译下面的一个超简单的模块,结果问题多多。
/*hello.c*/
#include /* We’re doing kernel work */
#include /* Specifically, a module */
/* Deal with CONFIG_MODVERSIONS */
/*
#if CONFIG_MODVERSIONS==1
#define MODVERSIONS
#include
#endif
*/
/* Initialize the module */
int init_module()
{
printk("Hello, world - this is the kernel speakingn");
return 0;
}
void cleanup_module()
{
printk("Short is the life of a kernel modulen");
}
当我直接用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!!
/*hello.c*/
#include /* We’re doing kernel work */
#include /* Specifically, a module */
/* Deal with CONFIG_MODVERSIONS */
/*
#if CONFIG_MODVERSIONS==1
#define MODVERSIONS
#include
#endif
*/
/* Initialize the module */
int init_module()
{
printk("Hello, world - this is the kernel speakingn");
return 0;
}
void cleanup_module()
{
printk("Short is the life of a kernel modulen");
}
当我直接用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!!
|
你的asm链接正确吗?