gpt4 book ai didi

c - 简单的Make文件错误

转载 作者:行者123 更新时间:2023-11-30 15:11:20 24 4
gpt4 key购买 nike

我正在尝试创建一个简单的 make 文件并使用它来构建一个简单的 c 程序。环境是在virtual box中,使用最新版本的ubuntu。我已经下载了 ubuntu 的 linux 头文件,但仍然收到错误。

你好.c

#include <linux/init.h>
#include <linux/module.h>

static int hello_init(void) {
printk(KERN_ALERT "TEST: Hello world, this is soliducode\n");
return 0;
}

static void hello_exit(void) {
printk(KERN_ALERT "TEST: Good byte, from soliduscode");
}

module_init(hello_init);
module_exit(hello_exit);

生成文件

obj-m += Hello.o

KDIR = /usr/src/linux-headers-4.2.0-16-generic

all:
$(MAKE) -C $(KDIR) SUBSIRS=$ modules

clean:
rm -rf *.o *.ko *.mod.* *.symvers *.order

错误

make -C /usr/src/linux-headers-4.2.0-16-generic SUBSIRS=modules
make[1]: Entering directory '/usr/src/linux-headers-4.2.0-16-generic'
arch/x86/Makefile:138: CONFIG_X86_X32 enabled but no binutils support
Makefile:669: Cannot use CONFIG_CC_STACKPROTECTOR_STRONG: -fstack-protector-strong not supported by compiler
HOSTCC scripts/basic/fixdep
scripts/basic/fixdep.c:462:1: fatal error: opening dependency file scripts/basic/.fixdep.d: Permission denied
}
^
compilation terminated.
scripts/Makefile.host:91: recipe for target 'scripts/basic/fixdep' failed
make[3]: *** [scripts/basic/fixdep] Error 1
Makefile:449: recipe for target 'scripts_basic' failed
make[2]: *** [scripts_basic] Error 2
make[2]: *** No rule to make target 'arch/x86/entry/syscalls/syscall_32.tbl', needed by 'arch/x86/entry/syscalls/../../include/generated/asm/syscalls_32.h'. Stop.
arch/x86/Makefile:184: recipe for target 'archheaders' failed
make[1]: *** [archheaders] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.2.0-16-generic'
Makefile:6: recipe for target 'all' failed
make: *** [all] Error 2

最佳答案

您的内核配置似乎无效。

有文档说明如何在 Ubuntu 上构建自己的内核,例如 https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel

关于c - 简单的Make文件错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35690076/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com