创建Linux模块时运行Makefile(在C中)出错

时间:2017-05-06 23:24:50

标签: c linux makefile

我有一个代码,我需要编译它。但是,我无法在计算机上运行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

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

非常感谢您提前

1 个答案:

答案 0 :(得分:0)

造成dependencies { compile('org.springframework.boot:spring-boot-starter-quartz') compile('org.springframework.boot:spring-boot-starter-web') compile('com.fasterxml.jackson.module:jackson-module-kotlin') compile('com.vaadin:vaadin-spring-boot-starter') compile('org.flywaydb:flyway-core') compile("org.jetbrains.kotlin:kotlin-stdlib-jdk8") compile("org.jetbrains.kotlin:kotlin-reflect") compile("com.h2database:h2") compile("eu.vaadinonkotlin:vok-rest:0.6.2") compile('org.codehaus.groovy:groovy-all:2.5.4') compile("org.flywaydb:flyway-core:5.2.0") compile "org.grails:gorm-hibernate5-spring-boot:6.1.6.RELEASE" compile "org.hibernate:hibernate-core:5.1.0.Final" compile "org.hibernate:hibernate-ehcache:5.1.0.Final" runtime "org.apache.tomcat:tomcat-jdbc:8.5.0" runtime "org.apache.tomcat.embed:tomcat-embed-logging-log4j:8.5.0" runtime "org.slf4j:slf4j-api:1.7.10" } 错误的原因有很多。

1)编译目录中的空格<==这就是你

2)CONFIG_X86_X32 enabled but no binutils support未安装

3)尝试用无特权的用户编译根拥有的内核源目录