linux – 如何针对新的源代码编译内核模块
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了linux – 如何针对新的源代码编译内核模块,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2524字,纯文字阅读大概需要4分钟。
内容图文
![linux – 如何针对新的源代码编译内核模块](/upload/InfoBanner/zyjiaocheng/967/b0b3a004558445979d034ab501854c59.jpg)
我正在尝试编译Hello World模块.我的系统中有一个新的Ubuntu没有任何编译内核.
我的内核是:
2.6.32-34泛型
我给了以下Makefile并得到了错误:
obj-m += hello-1.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
# make
make -C /lib/modules/2.6.32-34-generic/build M=/home/james/Desktop/hello modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.32-34-generic'
make[2]: *** No rule to make target `/home/james/Desktop/hello/hello-1.c', needed by `/home/james/Desktop/hello/hello-1.o'. Stop.
make[1]: *** [_module_/home/james/Desktop/hello] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-2.6.32-34-generic'
make: *** [all] Error 2
我的/lib/modules/2.6.32-34-generic的内容是
total 3864
lrwxrwxrwx 1 root root 40 2011-11-05 15:55 build -> /usr/src/linux-headers-2.6.32-34-generic
drwxr-xr-x 2 root root 4096 2011-11-05 15:49 initrd
drwxr-xr-x 10 root root 4096 2011-11-05 15:49 kernel
.......................................................
.......................................................
文件夹/usr/src/linux-headers-2.6.32-34-generic存在.
由于它没有工作,我下载了linux-headers-2.6.32-34-generic source from Ubuntu并编译并将我的Makefile更改为:
obj-m += hello-1.o
all:
make -C /usr/src/linux-2.6.32/ M=$(PWD) modules
clean:
make -C /usr/src/linux-2.6.32/ M=$(PWD) clean
#make
make -C /usr/src/linux-2.6.32/ M=/home/james/Desktop/hello modules
make[1]: Entering directory `/usr/src/linux-2.6.32'
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/src/linux-2.6.32/Module.symvers
is missing; modules will have no dependencies and modversions.
make[2]: *** No rule to make target `/home/james/Desktop/hello/hello-1.c', needed by `/home/james/Desktop/hello/hello-1.o'. Stop.
make[1]: *** [_module_/home/james/Desktop/hello] Error 2
make[1]: Leaving directory `/usr/src/linux-2.6.32'
make: *** [all] Error 2
有人可以帮我解决这个问题.http://packages.ubuntu.com/lucid-updates/devel/linux-headers-2.6.32-34-generic
我有一些一般性问题要问.
在全新安装之后,编译内核的最佳方法是什么.在我编译内核并构建了一个模块后,它可以更早地完美运行.但在这种情况下我无法知道该怎么做
解决方法:
make[2]: * No rule to make target
/home/james/Desktop/hello/hello-1.c', needed by
/home/james/Desktop/hello/hello-1.o’. Stop
您在第一次编译中遇到此错误,因为/ home / james / Desktop / hello /目录中缺少hello-1.c文件.
内容总结
以上是互联网集市为您收集整理的linux – 如何针对新的源代码编译内核模块全部内容,希望文章能够帮你解决linux – 如何针对新的源代码编译内核模块所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。