[英]Compiling Linux kernel - hello world
I am trying to compile the Linux kernel: http://tldp.org/LDP/lkmpg/2.6/html/lkmpg.html 我正在尝试编译Linux内核: http : //tldp.org/LDP/lkmpg/2.6/html/lkmpg.html
I have a simple hello world program hello-1.cpp 我有一个简单的hello world程序hello-1.cpp
#include <linux/module.h>
#include <linux/kernel.h>
int init_module(void)
{
return 0;
}
void cleanup_module(void)
{
}
But I am trying to build it using the Makefile: 但我正在尝试使用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
I get a couple of errors. 我收到了一些错误。
make -C /home/pacman/linux-2.6.34.11/2.6.35.6-45.fc14.i686/build M=/home/pacman/p1 modules
make: *** /home/pacman/linux-2.6.34.11/2.6.35.6-45.fc14.i686/build: No such file or directory. Stop.
make: * [all] Error 2 make: * [all]错误2
Am I forgetting to define something? 我忘了定义什么吗?
Rename hello-1. 重命名为hello-1。 cpp to hello-1. cpp to hello-1。 c (modules must be written in C) and add the lines: c (模块必须用C编写)并添加以下行:
module_init(init_module);
module_exit(cleanup_module);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.