1

I try to built modular programming Makefile for compiling a module named hello-1.c. I researched create make file and built video but i couldn't success.

My code :

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

int init_module(void)
{
    printk(KERN_INFO "Hello world \n");
    return 0;
}

void cleanup_module(void)
{
    printk(KERN_INFO "Goodbye world \n");
}

1 Answer 1

3

if you look up youtube modular programming , it tell you how to compile.  To learn more on how to compile modules which are not part of the official kernel  see file linux/Documentation/kbuild/modules.txt.

Makefile for compiling a module named your-file-name--1.c:

 obj-m += your-file-name-1.o

all:

 make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

clean:  

make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.