Re: regarding kernel version 2.6.9

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Hari,
On 1/11/06, hari krishna <kernel2006hari@xxxxxxxxxxxxxx> wrote:
hi kernel lovers,

my sysyem is red hat enterprise linux of linux version 2.6.9

i compiled the program given in oreilly device drivers 3rd edition .

    #include <linux/init.h>
    #include <linux/module.h>
    #include <linux/kernel.h>
    MODULE_LICENCE("Dual BSD/GPL");
    static int hello_init(void)
    {
        printk(KERN_ALERT "Hello, world\n");
        return 0;
    }

    static void hello_exit(void)
    {
        printk(KERN_ALERT "Goodbye, cruel world\n");
    }

    module_init(hello_init);
    module_exit(hello_exit);

but i got the below errors of

root@ihawk ddlinux]# gcc -c hello1.c
hello1.c:4: syntax error before string constant
hello1.c:4: warning: data definition has no type or storage class
hello1.c: In function `hello_init':
hello1.c:7: `KERN_ALERT' undeclared (first use in this function)
hello1.c:7: (Each undeclared identifier is reported only once
hello1.c:7: for each function it appears in.)
hello1.c:7: syntax error before string constant
hello1.c: In function `hello_exit':
hello1.c:13: `KERN_ALERT' undeclared (first use in this function)
hello1.c:13: syntax error before string constant

    Remember you are doing kernel  Module programming not compiling simple C program.  Use following Makefile
****************************************************************************
obj-m   := hello1.o

KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD       := $(shell pwd)

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

clean:
        rm -rf *.o  .*.cmd *.ko *.mod.c
**************************************************************************
    For Loading modules use insmod and removing module use rmmod. To use this command you need to be root user.

regards,
Parag. 
 

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux