No rule to make target 'lib/sha256.c' 编译内核模块时报错
No rule to make target 'lib/sha256.c' error when compiling kernel module
我正在尝试在 Fedora 28 中编译内核模块。我当前的内核是 4.17.3-200.fc28.x86_64
。我的 hello.c 是
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_INFO */
#include <linux/init.h> /* Needed for the macros */
static int __init hello_2_init(void)
{
printk(KERN_INFO "Hello, world 2\n");
return 0;
}
static void __exit hello_2_exit(void)
{
printk(KERN_INFO "Goodbye, world 2\n");
}
module_init(hello_2_init);
module_exit(hello_2_exit);
我的 Makefile 是
obj−m += hello.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
我在尝试编译时遇到此错误。最初我认为错误是由于 ssl 库。所以我为fedora安装了openssl-devel
。但我仍然遇到同样的错误。
make -C /lib/modules/4.17.3-200.fc28.x86_64/build M= modules
make[1]: Entering directory '/usr/src/kernels/4.17.3-200.fc28.x86_64'
CHK include/config/kernel.release
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
make[2]: *** No rule to make target 'lib/sha256.c', needed by 'arch/x86/purgatory/sha256.o'. Stop.
make[1]: *** [arch/x86/Makefile:263: archprepare] Error 2
make[1]: Leaving directory '/usr/src/kernels/4.17.3-200.fc28.x86_64'
make: *** [Makefile:4: all] Error 2
如何解决这个错误?
obj-m := FILENAME.o
KERNELDIR ?= /lib/modules/$(shell uname -r)/build <br/>
PWD := $(shell pwd)
all:
default
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
试试这个 Makefile 或在控制台中写入:
make -C /lib/modules/`uname -r`/build M=`pwd` modules obj-m=FILENAME.o
将 FILENAME 替换为您的文件名!
我正在尝试在 Fedora 28 中编译内核模块。我当前的内核是 4.17.3-200.fc28.x86_64
。我的 hello.c 是
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_INFO */
#include <linux/init.h> /* Needed for the macros */
static int __init hello_2_init(void)
{
printk(KERN_INFO "Hello, world 2\n");
return 0;
}
static void __exit hello_2_exit(void)
{
printk(KERN_INFO "Goodbye, world 2\n");
}
module_init(hello_2_init);
module_exit(hello_2_exit);
我的 Makefile 是
obj−m += hello.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
我在尝试编译时遇到此错误。最初我认为错误是由于 ssl 库。所以我为fedora安装了openssl-devel
。但我仍然遇到同样的错误。
make -C /lib/modules/4.17.3-200.fc28.x86_64/build M= modules
make[1]: Entering directory '/usr/src/kernels/4.17.3-200.fc28.x86_64'
CHK include/config/kernel.release
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
make[2]: *** No rule to make target 'lib/sha256.c', needed by 'arch/x86/purgatory/sha256.o'. Stop.
make[1]: *** [arch/x86/Makefile:263: archprepare] Error 2
make[1]: Leaving directory '/usr/src/kernels/4.17.3-200.fc28.x86_64'
make: *** [Makefile:4: all] Error 2
如何解决这个错误?
obj-m := FILENAME.o
KERNELDIR ?= /lib/modules/$(shell uname -r)/build <br/>
PWD := $(shell pwd)
all:
default
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
试试这个 Makefile 或在控制台中写入:
make -C /lib/modules/`uname -r`/build M=`pwd` modules obj-m=FILENAME.o
将 FILENAME 替换为您的文件名!