当前位置:  技术问答>linux和unix

hello world driver

    来源: 互联网  发布时间:2016-06-13

    本文导语:  看linux设备驱动第二章hello world模块 测试之,产生以下错误代码 xxx:/usr/local/moudle-driver# make make -C /usr/local/linux-2.6.22.14 M=/usr/local/moudle-driver modules make[1]: Entering directory `/usr/local/linux-2.6.22.14'   ERROR: Kernel configura...

看linux设备驱动第二章hello world模块

测试之,产生以下错误代码

xxx:/usr/local/moudle-driver# make
make -C /usr/local/linux-2.6.22.14 M=/usr/local/moudle-driver modules
make[1]: Entering directory `/usr/local/linux-2.6.22.14'

  ERROR: Kernel configuration is invalid.
         include/linux/autoconf.h or include/config/auto.conf are missing.
         Run 'make oldconfig && make prepare' on kernel src to fix it.


  WARNING: Symbol version dump /usr/local/linux-2.6.22.14/Module.symvers
           is missing; modules will have no dependencies and modversions.

  CC [M]  /usr/local/moudle-driver/hello.o
cc1: error: invalid option `regparm=3'
cc1: error: invalid option `preferred-stack-boundary=2'
cc1: error: invalid option `accumulate-outgoing-args'
cc1: error: unrecognized command line option "-Wno-pointer-sign"
cc1: error: unrecognized command line option "-fno-stack-protector"
make[2]: *** [/usr/local/moudle-driver/hello.o] Error 1
make[1]: *** [_module_/usr/local/moudle-driver] Error 2
make[1]: Leaving directory `/usr/local/linux-2.6.22.14'
make: *** [modules] Error 2


按照提示进入kernel src run make oldconfig
又错了,帖上一点错误信息

xxx:/usr/local/linux-2.6.22.14# make oldconfig
  HOSTCC  scripts/basic/fixdep
scripts/basic/fixdep.c:107:23: error: sys/types.h: No such file or directory
scripts/basic/fixdep.c:108:22: error: sys/stat.h: No such file or directory
scripts/basic/fixdep.c:109:22: error: sys/mman.h: No such file or directory
scripts/basic/fixdep.c:110:20: error: unistd.h: No such file or directory
scripts/basic/fixdep.c:111:19: error: fcntl.h: No such file or directory
scripts/basic/fixdep.c:112:20: error: string.h: No such file or directory
scripts/basic/fixdep.c:113:20: error: stdlib.h: No such file or directory
scripts/basic/fixdep.c:114:19: error: stdio.h: No such file or directory


请问我该怎么配置kernel, 系统缺少那些东东?

|
再编译下内核,
内核源码包必须与自己机子的内核版本一致。
不然不容易调试。

我每次Make config出问题之后都直接删除整个目录,
再解压源码包,重新make oldconfig或make menuconfig

|
你的 kernel 目录很可能不正确, 
建议你重新编译kernel。
Makefile 里,明确指出kernel 的路径。

|
scripts/basic/fixdep.c:107:23: error: sys/types.h: No such file or directory 
scripts/basic/fixdep.c:108:22: error: sys/stat.h: No such file or directory 
scripts/basic/fixdep.c:109:22: error: sys/mman.h: No such file or directory 
scripts/basic/fixdep.c:110:20: error: unistd.h: No such file or directory 
scripts/basic/fixdep.c:111:19: error: fcntl.h: No such file or directory 
scripts/basic/fixdep.c:112:20: error: string.h: No such file or directory 
scripts/basic/fixdep.c:113:20: error: stdlib.h: No such file or directory 
scripts/basic/fixdep.c:114:19: error: stdio.h: No such file or directory 
这些头文件都找不到,估计你的内核有问题,也有可能是你的内核没有编译过。

|
试试:

# make defconfig

|
貌似你安装的 gnu 开发工具包有问题,或者没有安装

|

编译内核操作流程 ──为新手指南
http://fedora.linuxsir.org/main/?q=node/66

先编译你的内核。

|
应该就是内核没有编译过的问题

|
你的内核树没有编译,重新编译一个就OK了,或者重装LINUX,选择安装源代码。

|
当前运行的内核不是你编译模块的时候编译的内核?

建议安装kernel header file, 然后针对/lib/modules/`uname -r`/build 编译内核。

建议用ubuntu

|
你没有进入SU权限。有了这个权限就可以了,如果不想使用这个,就得自己在环境变量里加上地址,或者你直接操作这个命令的地址就可以了。呵呵,最初我也遇到过。

|
Makefile不对

给你个看看
============
obj-m += helloworld.o
KDIR:= /lib/modules/$(shell uname -r)/build
PWD:= $(shell pwd)
default:
$(MAKE) -C $(KDIR) M=$(PWD) modules 
clean : 
rm  *.o *.ko *.symvers *.mod.c 
===================

而且 你的lib库 可能安装有问题,自己查下

    
 
 

您可能感兴趣的文章:

  • 在docker容器中运行hello world!
  • 如果没有操作系统,Hello World可以运行吗?如果要在一台没有操作系统的机器上运行Hello World需要什么?应该怎么实现?
  • 据说这是史上最变态的6个C语言Hello, World程序
  • hello world在终端里显示
  • Hello world失败.........
  • 怎么连个hello world都通不过了?
  • char message[] = "Hello World";問題
  • Hello world程序简单问题??
  • 我用cc为何不能编译Hello,World。
  • 教我在linux上,做出第一个hello world
  • 奇怪!我的Hello World执行之后为什么没反应?
  • 一个HELLO WORLD的问题。
  • 简单的hello world程序,就是闹不明白!
  • GCC编译的Hello World为何不能执行
  • mips交叉编译自写的HELLO WORLD无法运行
  • NOSQL iis7站长之家
  • 关于Linux Device Ddriver 3的hello world的例子?
  • ———我是个菜菜鸟:Hello World 例子也不过,请问为啥!————
  • gcc如何才能生成一个几十k之内的hello world的程序(不依赖于任何so)?
  • Python 第一步 hello world
  • "Hello,World"都通不过。HELP!!!
  •  
    本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
    本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。












  • 相关文章推荐
  • gcc -o hello hello.c
  • 我已经编译了一个hello.class的文件,为什么,使用java hello还是提示没有hello.class这个类呢?
  • 编译一个hello.cpp文件后 ,再list ,怎么会多了个hello.cpp~文件?
  • 如何设置服务器, 使http://localhost/hello.php变成http://www.example.com/hello.php生效?
  • 一个可执行文件在它所在的目录执行它,必须这样 ./hello , 直接 hello 就不行???
  • 我写了一个servlet--hello.hello,放在tomcat的web-inf/classes下,但不知该如何访问?在线等待
  • 使用hello-objs该项编译hello驱动模块,竟然会提示失败..
  • 我的小hello程序运行不起来?
  • 菜鸟求助linux最最基本的HELLO函数错误
  • hello.ko模块的加载与卸载
  • 请教如何用java虚拟机运行hello.class文件,谢谢。
  • gcc编译hello.c出现问题.我是新手
  • sco下用gcc编译hello.cpp出来的可执行文件居然有2800280字节,而且运行出错???
  • JavaScript 的 OAuth 框架 Hello.js
  • gdb调试问题:用break hello.c: 10 设置断点怎么不成功??
  • hello,word也出现错误了~~~欺负我~~~
  • linux 设备驱动程序 hello.ko 问题
  • 在LINUX下编译hello.c报错
  • 简单问题,hello world
  • 在哪里下载sun的jdk,下载了之后如何编写自己的第一个hello程序呢?


  • 站内导航:


    特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

    ©2012-2021,,E-mail:www_#163.com(请将#改为@)

    浙ICP备11055608号-3