Thread: first module programming Error

  1. #1
    Registered User
    Join Date
    Aug 2008
    Posts
    2

    first module programming Error

    hi
    i want to start module programming but i don't know how;
    i write a module Hello-1.c and compile it with a make file but the following Error has appear :

    Code:
    make -C /lib/modules/2.6.13-15-default/build M=/root/Desktop modules
    make[1]: Entering directory `/usr/src/linux-2.6.13-15-obj/i386/default'
    make[1]: *** No rule to make target `modules'. Stop.
    make[1]: Leaving directory `/usr/src/linux-2.6.13-15-obj/i386/default'
    make: *** [all] Error 2
    the Hello-1.c:

    Code:
    #include <linux/module.h> /*needed by all modules */
    #include <linux/kernel.h> /*needed for Macros like KERN_INFO */
    
    int init_module(void) /* this
    function is called as initialization for all modules */
    
    {
    printk(KERN_INFO “Hello World1.\n”);
    
    /* if this function returns non
    zero means init_module failed and
    this module can’t be loaded .
    */
    return 0;
    }
    
    void cleanup_module(void) /* it is
    called when module is terminated and unloaded */
    {
    printk( KERN_INFO “Goodbye World1.\n”);
    }
    the Makefile:

    Code:
    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

  2. #2
    Registered User pornoshome's Avatar
    Join Date
    Aug 2008
    Posts
    5
    just add the following line after the include statements and check whether the module compiles.
    Code:
    MODULE_LICENSE("Dual BSD/GPL");

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 04:09 AM
  2. Quantum Random Bit Generator
    By shawnt in forum C++ Programming
    Replies: 62
    Last Post: 06-18-2008, 10:17 AM
  3. more then 100errors in header
    By hallo007 in forum Windows Programming
    Replies: 20
    Last Post: 05-13-2007, 08:26 AM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. ras.h errors
    By Trent_Easton in forum Windows Programming
    Replies: 8
    Last Post: 07-15-2005, 10:52 PM