Click here to Skip to main content
14,921,764 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I wanted to create a Linux kernel module that takes my name, and two integers as arguments, and then prints the name and the sum of those numbers on standard output. Unfortunately the file is not compiling. I get the message: make[2]: *** No rules to make object '/home/rafal/Core/core.o', required by '/home/rafal/Core/core.mod'. Stop. Below I paste the Makefile and module code. Someone suggest what is wrong.

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

static char *my_name= "Janusz";
module_param(my_name, charp, 0644);
MODULE_PARM_DESC(my_name, "String");

static int first_value = 1;
module_param(first_value, int, 0644);
MODULE_PARM_DESC(first_value, "Integer");

static int second_value = 2;
module_param(second_value, int, 0644);
MODULE_PARM_DESC(second_value, "Integer");

static int __init my init(void)
int sum;
sum= first_value+second_value;

    printk(KERN_INFO "[parameters] Init module!\n");
    printk(KERN_INFO "[parameters] my_name = %s\n", my_name);
    printk(KERN_INFO "[parameters] sum = %d\n", sum);

    return 0;

void __exit my_exit(void)


obj-m := core.o
KERNELDIR = /lib/modules/$(shell uname -r)/build

    $(MAKE) -C $(KERNELDIR) M=$(PWD) modules

    $(MAKE) -C $(KERNELDIR) M=$(PWD) clean

What I have tried:

I have no more idea whats is wrong
Richard MacCutchan 30-Apr-21 3:52am
You need to add the rule that creates core.o from its source code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900