kernel modules

Discussion in 'C Programming' started by alice, Dec 3, 2004.

  1. alice

    alice Guest

    hi all,
    First of all I would apologize in case this the wrong group for
    posting this article.
    I'm trying to write small Linux kernel modules.I compile them with the
    following command

    gcc -c test.c

    which produces the file test.o

    Now when I tries to load the module using insmod command it gives the
    following error
    message-

    test.o: kernel-module version mismatch
    test.o was compiled for kernel version 2.4.20
    while this kernel is version 2.4.20-8(custom)


    Id tried to disable the version support from my kernel by compiling it
    as follows-
    Id marked Y for the kernel module version
    information(CONFIG_MODCONVERSIONS).

    However,Im not sure that whether the new Kernel which I'd booted
    really does have the
    version information disabled as it is also giving the same error on
    using the insmod
    command.

    Here is the file test.c:

    #include<linux/config.h>
    #if defined(CONFIG_MODCONVERSIONS) && !defined(MODVERSIONS)
    # define MODVERSIONS
    #endif


    #ifdef MODVERSIONS
    # include <linux/modversions.h>
    #endif


    #define MODULE
    #include<linux/module.h>

    int init_module(void){
    printk("this is a test\n");
    return 0;
    }

    void cleanup_module(void){
    printk("bye!\n");
    return ;
    }
     
    alice, Dec 3, 2004
    #1
    1. Advertising

  2. alice

    -berlin.de Guest

    alice <> wrote:
    > First of all I would apologize in case this the wrong group for
    > posting this article.
    > I'm trying to write small Linux kernel modules.I compile them with the
    > following command


    > gcc -c test.c


    > which produces the file test.o


    Sorry, but you're really wrong here, Linux kernel modules aren't
    really something you can do with standard C and the special magic
    required to compile them is even more off-topic here. Please take
    this to e.g. comp.os.linux.development.system where it's exactly
    on-topic.
    Regards, Jens
    --
    \ Jens Thoms Toerring ___ -berlin.de
    \__________________________ http://www.toerring.de
     
    -berlin.de, Dec 3, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. yogesh
    Replies:
    3
    Views:
    604
    Kenny McCormack
    Feb 12, 2006
  2. Thomas Ploch
    Replies:
    2
    Views:
    871
    Laurent Pointal
    Mar 7, 2007
  3. InuY4sha

    Kernel modules syntaxes

    InuY4sha, Apr 9, 2008, in forum: C Programming
    Replies:
    1
    Views:
    373
    Antoninus Twink
    Apr 9, 2008
  4. Replies:
    3
    Views:
    183
  5. Lars Gierth
    Replies:
    6
    Views:
    239
    David Masover
    Mar 20, 2010
Loading...

Share This Page