2014-09-13 32 views
0

我在VirtualBox上運行Ubuntu 14.04 64位MAC Macbook Pro。我想要運行hello_kernel.c中的以下內容。i586-poky-linux:無法生成arch/x86/tools/relocs所需的目標`arch/x86/tools/relocs.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); 

我已經安裝了i586的,狹小Linux的在/home/esp/SDK/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' 

我沒有看到~/SDK/sysroots/i586-poky-linux/usr/src/kernel/arch/x86/tools/relocsrelocs.c

回答

0

找到解決方案!我的i586-poky-linux內核安裝中缺少一些腳本。要生成這些腳本,請在SDK/sysroots/i586-poky-linux/usr/src/kernel中運行sudo make scripts。這將生成所需的腳本,一切正常。 :)