用cygwin编译内核模块的问题,急,在线等待!!

wgc12321 2004-05-04 10:33:22
我在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!!
...全文
126 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
wgc12321 2004-05-14
  • 打赏
  • 举报
回复
luckydean(老怪),去天网搜一下arm-linux-gcc,肯定能找到
luckydean 2004-05-13
  • 打赏
  • 举报
回复
to潇湘夜雨:怎样看它的链接:)
tianxiangyuan 2004-05-11
  • 打赏
  • 举报
回复
你的asm链接正确吗?
luckydean 2004-05-11
  • 打赏
  • 举报
回复
小春:我的cywin没有arm-linux-gcc,哪里有的下载,怎样建立arm-linux交叉编译环境?谢了!
wgc12321 2004-05-06
  • 打赏
  • 举报
回复
自己搞定
using kernel for compiling our modules
1.把源文件(比如是hello.c)放到kernel的一个目录下,比如drivers/misc
然后修改config.in和makefile
在config.in里加上
dep_tristate 'Hello World Module' CONFIG_MCP_UCB1200_HELLO
在makefile里加上
obj-$(CONFIG_MCP_UCB1200_HELLO) += hello.o

如果要动态加载的话内核配置中make menuconfig,选上Loadable module support
然后将要动态加载的模块设置为[M]

最后在内核根目录下执行make modules

2.根据你的内核情况修改下列makefile文件:
#makefile

TOPDIR=/usr/src/linux-2.4.19
obj-m = hello.o
build:
$(MAKE) -C $(TOPDIR) SUBDIRS=$(shell pwd) modules
include /usr/src/linux-2.4.19/Rules.make
install:
@# completely broken ATM - removes the whole dir
@#make -C $(KSRC) SUBDIRS=`pwd` modules_install
@echo "Install it yourself ..."
clean: @# kbuild can't handle this (yet ?)
@#make -C $(KSRC) SUBDIRS=`pwd` clean
rm -f *.o *.ko *.mod.o *.mod.c .*.{cmd,flags}
rm -rf config.status config.log autom4te*.cache

然后make就行了
wgc12321 2004-05-05
  • 打赏
  • 举报
回复
怎么没人帮我了?
五一节高手都放假了?
wgc12321 2004-05-04
  • 打赏
  • 举报
回复
自己up
wxywh 2004-05-04
  • 打赏
  • 举报
回复
关注,顶。

4,436

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 内核源代码研究区
社区管理员
  • 内核源代码研究区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧