【问题标题】:Error in running Makefile (in C) when creating a Linux Module创建 Linux 模块时运行 Makefile(C 语言)时出错
【发布时间】:2017-05-06 23:24:49
【问题描述】:

我在下面有一个代码,我需要编译它。但是,我无法在我的计算机上运行 Makefile

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

int
simple_init(void)
{
  printk("Loading module\n");
  return 0;
}

void
simple_exit(void)
{
  printk("Removing module\n");
}

module_init(simple_init);
module_exit(simple_exit);

MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Simple Module");

生成文件:

obj-m := simple.o
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)

default:
    $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules

clean:
    $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) clean

问题是:当我在终端输入 Make 时出现以下错误:

make -C /lib/modules/4.4.0-75-generic/build 
SUBDIRS=/home/caiquefortunato/Área de Trabalho/kernel modules
make[1]: Entering directory '/usr/src/linux-headers-4.4.0-75-generic'
arch/x86/Makefile:148: CONFIG_X86_X32 enabled but no binutils support
Makefile:693: Cannot use CONFIG_CC_STACKPROTECTOR_STRONG: -fstack-
protector-strong not supported by compiler
make[1]: *** No rule to make target 'de'.  Pare.
make[1]: Leaving directory '/usr/src/linux-headers-4.4.0-75-generic'
Makefile:19: recipe for target 'default' failed
make: *** [default] Error 2

我必须做些什么才能让它发挥作用?我需要安装一些东西吗?

非常感谢您

【问题讨论】:

  • make 可能会在文件夹路径中有空格时搞砸。尝试将构建文件夹复制到没有空格的路径并再次运行make
  • 已解决。非常感谢。 =D

标签: c linux makefile


【解决方案1】:

CONFIG_X86_X32 enabled but no binutils support 错误有几个原因。

1) 编译目录中的空格

2) binutils 未安装

3) 尝试使用非特权用户编译 root 拥有的内核源目录

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-24
    • 2014-04-16
    • 2021-03-25
    • 1970-01-01
    相关资源
    最近更新 更多