Find the answer to your Linux question:
Results 1 to 4 of 4
Hi All, I just tried to compile the Hello.c Module as stated in the "Linus Kernel Module Programming Guide" and i'm getting the follwing output. linux-toej:/home/raj/program # make make -C ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Nov 2006
    Posts
    2

    Hello Module - Compilation creates Modules.symvers


    Hi All,

    I just tried to compile the Hello.c Module as stated in the "Linus Kernel Module Programming Guide" and i'm getting the follwing output.

    linux-toej:/home/raj/program # make
    make -C /lib/modules/2.6.16.21-0.25-smp/build M=/home/raj/program modules
    make[1]: Entering directory `/usr/src/linux-2.6.16.21-0.25-obj/i386/smp'
    make -C ../../../linux-2.6.16.21-0.25 O=../linux-2.6.16.21-0.25-obj/i386/smp modules
    Building modules, stage 2.
    MODPOST
    make[1]: Leaving directory `/usr/src/linux-2.6.16.21-0.25-obj/i386/smp'


    Instead of creating hello.ko I have 2 files namely 'Modules.symvers' , '.tmp_versions'

    DIR command is shown below:


    linux-toej:/home/raj/program # dir
    total 8
    -rw-r--r-- 1 root root 190 2006-11-13 19:05 hello.c
    -rw-r--r-- 1 root root 190 2006-11-13 19:12 Makefile
    -rw-r--r-- 1 root root 0 2006-11-13 19:40 Modules.symvers
    drwxr-xr-x 2 root root 48 2006-11-14 19:57 .tmp_versions



    Please help me to compile this module. Seems I messed up something with the Kernel source.

    Thanks a lot,

    Raj

  2. #2
    Linux User fernape's Avatar
    Join Date
    Dec 2005
    Location
    Holland
    Posts
    301
    Are u using, exactly the same Makefile that the Guide says?
    Do you have your kernel sources properly installed?

    Best Regards

  3. #3
    Just Joined!
    Join Date
    Nov 2006
    Posts
    2
    Here is the code i'm trying to compile.

    hello-1.c
    #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=/home/raj/program modules
    clean:
    make −C /lib/modules/$(shell uname -r)/build M=/home/raj/program clean

    ~

  4. #4
    Just Joined!
    Join Date
    Feb 2007
    Posts
    1

    2.6 kernel programming

    hey guy ...
    I am using fedora core 6.0 . I am trying to compile a kernel hello world program .. buts its not compiling .. its giving lots of error . Can any one please tell me how to compile a kernel program .
    but the same program is compiling in 2.4 kernel .


    Here is my code ....
    /************************************************** *******************************/
    #define __KERNEL__

    #define MODULE


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

    MODULE_LICENSE("GPL");

    int int_module()
    {
    printk(KERN_INFO"\n hello world \n");
    }

    void cleanup_module()
    {
    printk(KERN_INFO "\n Goodbye kernel\n");
    }
    /************************************************** *************************************/


    And i am compiling by this command ....

    gcc -c -I /usr/src/kernels/2.6.18-1.2798.fc6-i686/include/linux hello.c

    Can any one please tell me .whats worng in my progam ....

    Regards,
    dinesh

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •