use*_*115 4 c linux ubuntu makefile 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");
}
Run Code Online (Sandbox Code Playgroud)
我的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
Run Code Online (Sandbox Code Playgroud)
这个文件都在文件夹/ 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
Run Code Online (Sandbox Code Playgroud)
任何人都可以知道根本原因是什么?我知道这很简单,我还是不能从这里出来?
谢谢
$(shell uname ?r)
^
This is not a - (dash , minus) character.
Run Code Online (Sandbox Code Playgroud)
你要
$(shell uname -r)
Run Code Online (Sandbox Code Playgroud)