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

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

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

thankQ ,..... it worked....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.