简体   繁体   English

Linux内核模块编程Makefile错误

[英]Linux Kernel Module programming Makefile error

I am trying to compile a "Hello world" linux kernel module programming in Fedora 14 . 我正在尝试在Fedora 14编译“ Hello world” linux kernel module编程。 My kernel version is " 2.6.35.14-97.fc14.i686 " which i am referring to /lib/modules/$(shell uname -r)/build M=$(PWD) modules in the make file to compile my hello.o program. 我的内核版本是“ 2.6.35.14-97.fc14.i686 ”,我指的是make文件中的/lib/modules/$(shell uname -r)/build M=$(PWD)模块来编译我的hello.o程序。

This "build" file showing it as special file and linked to source in /lib/module/2.6....i686/ folder. 此“构建”文件将其显示为特殊文件,并链接到/lib/module/2.6....i686/文件夹中的源。

When i compile my code getting below error. 当我编译我的代码时出现错误以下。

make -C /lib/modules/2.6.35.14-97.fc14.i686/build M=/root/kernel modules
make: *** /lib/modules/2.6.35.14-97.fc14.i686/build: No such file or directory.  Stop.

My Makefile : 我的Makefile

obj-m +=hello.o

all:
        make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

Please give me solution to run this module program. 请给我解决方案以运行此模块程序。

You should only need 'kernel-devel' which you can install using yum for it. 您只需要可以使用yum安装的“ kernel-devel”即可。 I use ubuntu and I just had to download the package 3.5.0-22-generic for it to work but a quick 'Kernal development module for Fedora' search on google led me Here Hope this helps. 我使用ubuntu,我只需要下载3.5.0-22-generic软件包即可使用,但是在Google上快速搜索“ Fedora的内核开发模块”使我在这里希望这对您有所帮助。

尝试安装kernel-devel

yum install kernel-devel

编译内核并安装模块INSTALL_MOD_PATH = / path /,同时编译hello world .link模块路径,例如MAKE -C KDIR = INSTALL_MOD_PATH M ='$ PWD'模块

As suggested by others please install "kernel-devel". 根据其他人的建议,请安装“ kernel-devel”。 This worked perfectly for me. 这对我来说非常有效。

You can install it by: 您可以通过以下方式安装它:

yum install kernel-devel

You need to install the right version of kernel-devel ,you should append kernel version ( uname -r ) to the kernel-devel. 您需要安装正确的kernel-devel版本,应将内核版本( uname -r )附加到kernel-devel。

For example: I executed " yum install kernel-devel-4.8.6-300.fc25.x86_64 " and it worked. 例如:我执行了“ yum install kernel-devel-4.8.6-300.fc25.x86_64 ”,它成功了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM