我在Macbook Pro上的VirtualBox上运行Ubuntu 14.04 64位MAC。我在hello_kernel.c
中有以下要运行的内容。
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
static int __init enter(void)
{
printk(KERN_ALERT "Hello Kernel Galileo\n");
return 0;
}
static void __exit exit(void)
{
printk(KERN_ALERT "Bye kernel Galileo\n");
return;
}
module_init(enter);
module_exit(exit);
我在/home/esp/SDK/i586-poky-linux
安装了i586-poky-linux,这是我的Makefile
。
obj-m:= hello_kernel.o
ARCH=x86
CROSS_COMPILE=i586-poky-linux-
all:
make -C /home/esp/SDK/sysroots/i586-poky-linux/usr/src/kernel M=$(PWD) modules
clean:
rm -fr *.o
rm -fr *.ko
rm -fr *.mod.c
rm -fr *.order
rm -fr *.symvers
运行sudo make
时出现以下错误。
make[2]: Nothing to be done for `all'.
make[2]: *** No rule to make target `arch/x86/tools/relocs.c', needed by `arch/x86/tools/relocs'. Stop.
make[1]: *** [archscripts] Error 2
make[1]: Leaving directory `/home/esp/SDK/sysroots/i586-poky-linux/usr/src/kernel'
我在relocs
中看不到relocs.c
和~/SDK/sysroots/i586-poky-linux/usr/src/kernel/arch/x86/tools/
。
答案 0 :(得分:0)
找到解决方案!我的i586-poky-linux内核安装中缺少一些脚本。要生成这些脚本,请在sudo make scripts
中运行SDK/sysroots/i586-poky-linux/usr/src/kernel
。这将生成所需的脚本,一切正常。 :)