繁体   English   中英

编译linux内核的make文件时出问题?

[英]Issue while compiling make file for linux kernel?

我刚开始使用linux内核开发,我遇到编译make文件的问题。

这是你好世界的教程。

我的hello-1.c文件

*
* hello−1.c − The simplest kernel module.
*/
#include <linux/module.h>
/* Needed by all modules */
#include <linux/kernel.h>
/* Needed for KERN_INFO */
int init_module(void)
{
printk(KERN_INFO "Hello world 1.\n");
/*
* A non 0 return means init_module failed; module can't be loaded.
*/
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO "Goodbye world 1.\n");
}

我的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

这个文件都在文件夹/ home / kkr / Documents / HelloWorld中

当我运行make命令时,我的输出低于输出。

uname: extra operand `−r'
Try `uname --help' for more information.
make −C /lib/modules//build M=/home/kkr/Documents/HelloWorld modules
make[1]: Entering directory `/home/kkr/Documents/HelloWorld'
make[1]: *** No rule to make target `−C'.  Stop.
make[1]: Leaving directory `/home/kkr/Documents/HelloWorld'
make: *** [all] Error 2

任何人都可以知道根本原因是什么? 我知道这很简单,我还是不能从这里出来?

谢谢

$(shell uname −r)
              ^
           This is not a - (dash , minus) character.

你要

$(shell uname -r)

我最初遇到了同样的问题。

不应复制Makefile的内容。 复制将更改某些字符,因此'make'命令将不再识别它们。

要正确构建模块,您需要在Makefile中手动键入代码。

暂无
暂无

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

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