Find the answer to your Linux question:
Results 1 to 3 of 3
am trying to learn kernel propgramming.......but am having some fundamentals wrong. 1) am having mandriva 2007.....is it necessary to first configure the kernel and build it before inserting modules in ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2008
    Posts
    6

    error in compilation of first module


    am trying to learn kernel propgramming.......but am having some fundamentals wrong.

    1) am having mandriva 2007.....is it necessary to first configure the kernel and build it before inserting modules in 2.6 kernel series.

    2) am not having source in /usr/source so in which directory i should go and call make xconfig


    3) i understand what configuring a kernel means but what is meant by building a kernel.



    am trying to write a module but getting error in compilation

    #include <linux/init.h> /* Needed by all modules */
    #include <linux/kernel.h>/* Needed for KERN_ALERT */

    int init_module(void)
    {
    printk("Hello world 1.\n");
    // A non 0 return means init_module failed; module can't be loaded.
    return 0;
    }


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





    the make file for this program is::



    obj-m:=hello1.o


    all:
    make -C /lib/modules/`uname -r`/kernel/fs M=$(PWD) modules

    clean:
    make -C /lib/modules/'uname -r'/kernel/fs M=$(PWD) clean



    and the error encountered is::





    [neferteti@localhost prog 1]$ make
    make -C /lib/modules/`uname -r`/kernel/fs M=/home/neferteti/Documents/programs/kernel modules/prog 1 modules
    make[1]: Entering directory `/lib/modules/2.6.17-5mdv/kernel/fs'
    make[1]: *** No rule to make target `modules/prog'. Stop.
    make[1]: Leaving directory `/lib/modules/2.6.17-5mdv/kernel/fs'
    make: *** [all] Error 2

    ************************************************** *******

    please help me out with these doubts. I will truly appreciate your help.

  2. #2
    Linux Newbie raghaven.kumar's Avatar
    Join Date
    Mar 2008
    Location
    Bangalore, India
    Posts
    209

    Post

    dude,

    do uname -r for finding your kernel version

    find your kernel-devel installation for your kernel
    and install it.

    im not sure what mandriva is
    but if its debian-based, i suggest using apt-get for installation.

  3. #3
    Linux Newbie
    Join Date
    Mar 2008
    Location
    Hyderabad
    Posts
    109
    obj-m += hello1.o
    VERSION := $(shell uname -r)
    PWD := $(shell pwd)
    default:
    $(MAKE) -C /lib/modules/$(VERSION)/build M=$(PWD) modules

    May be you forgot += on the first line .

Posting Permissions

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