Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
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)

module_init(my_init);
module_exit(my_exit);


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

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

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


What I have tried:

I have no more idea whats is wrong
Posted
Comments
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