简单制作文件错误 [英] Simple Make File Error

查看:140
本文介绍了简单制作文件错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个简单的make文件,并使用它来构建一个简单的c程序.使用最新版本的ubuntu,该环境位于虚拟框中.我已经下载了ubuntu的linux头文件,但仍然收到错误消息.

I am trying to create a simple make file and using it to build a simple c program. The environment is in virtual box using the newest version of ubuntu. I have already downloaded the linux headers for ubuntu but still getting the error.

Hello.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);

Makefile

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

推荐答案

您的内核配置似乎无效.

It looks like your kernel config is invalid.

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

There is documentation how to build your own kernel on Ubuntu, e.g. https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel

这篇关于简单制作文件错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆