CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
可用分押宝游戏火热进行中... 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Linux/Unix社区 >  内核及驱动程序研究区

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

楼主wgc12321(小椿)2004-05-04 10:33:22 在 Linux/Unix社区 / 内核及驱动程序研究区 提问

我在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!!  
  问题点数:100、回复次数:8Top

1 楼wxywh()回复于 2004-05-04 11:13:11 得分 0

关注,顶。Top

2 楼wgc12321(小椿)回复于 2004-05-04 11:36:38 得分 0

自己upTop

3 楼wgc12321(小椿)回复于 2004-05-05 09:09:43 得分 0

怎么没人帮我了?  
  五一节高手都放假了?Top

4 楼wgc12321(小椿)回复于 2004-05-06 09:03:39 得分 0

自己搞定  
  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就行了Top

5 楼luckydean(~0~)回复于 2004-05-11 10:37:14 得分 0

小春:我的cywin没有arm-linux-gcc,哪里有的下载,怎样建立arm-linux交叉编译环境?谢了!Top

6 楼tianxiangyuan(潇湘夜雨)回复于 2004-05-11 10:58:54 得分 100

你的asm链接正确吗?Top

7 楼luckydean(~0~)回复于 2004-05-13 22:21:49 得分 0

to潇湘夜雨:怎样看它的链接:)Top

8 楼wgc12321(小椿)回复于 2004-05-14 08:30:11 得分 0

luckydean(老怪),去天网搜一下arm-linux-gcc,肯定能找到Top

相关问题

  • 编译内核模块的问题....(急)
  • 内核模块编译问题(菜鸟级问题)
  • 内核模块编译不过去,求助!
  • red hat9.0 内核升级编译后 声音模块的问题
  • 内核编译。。。
  • Red Hat Linux9.0编译超简单的内核模块出错,郁闷!
  • [求教]内核加载模块后,这部分内容编译在内核里的吗?
  • uclinux内核编译
  • *******是不是对内核模块编程然后再重新编译内核就可以把此模块整合到linux系统中
  • 内核编译告急!!!!!!

关键词

  • 编译
  • 模块
  • arm
  • gcc
  • linux
  • 内核
  • 如下
  • modversions
  • modules
  • lflags

得分解答快速导航

  • 帖主:wgc12321
  • tianxiangyuan

相关链接

  • CSDN Blog
  • 技术文档
  • 代码下载
  • 第二书店
  • 读书频道

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo