0

These two files i have created in som efolder in home dir
1)hello-1.c
2)Makefile


#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_INFO */
int init_module(void)
{
printk(KERN_INFO "Hello world 1.\n");
/*
* A non 0 return means init_module failed; module can't be loaded.
*/
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO "Goodbye world 1.\n");
}

---------------------------------------------------------------------------

Makefile:

obj−m += hello−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

------------------------------------------------------------------------------

when i tried
$ make
make: Nothing to be done for `all'.


i tried to compile the c file directly with gcc.

it is not able to find kernel.h and module.h

then i gave the whole path . even then it is giving some library errors only .

How can i made this first step SUCCESSFULL.,

pls help me.. i am very much interested in learning kernel.

thanks & regards
-vinay

3
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by vnykr
0

Makefile:

obj−m += hello−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


make −C /lib/modules/$(shell uname −r)/build M=$(PWD) modules should be tabbed in and
make −C /lib/modules/$(shell uname −r)/build M=$(PWD) clean should also be tabbed in like below
note: <tab> = tab space

Makefile:

obj−m += hello−1.o
all:
<tab>make −C /lib/modules/$(shell uname −r)/build M=$(PWD) modules
clean:
<tab>make −C /lib/modules/$(shell uname −r)/build M=$(PWD) clean

0

Please use code tags. You will get faster replies when using correctly formatted queries.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.