gpt4 book ai didi

c - 为 linux 内核编译 make 文件时出现问题?

转载 作者:太空狗 更新时间:2023-10-29 15:55:12 26 4
gpt4 key购买 nike

我刚刚开始 linux 内核开发,但在编译 make 文件时遇到问题。

这是hello world的教程。

我的 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");
}

我的生成文件

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)

关于c - 为 linux 内核编译 make 文件时出现问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18936975/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com