Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Error in compiling hello world module

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


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

    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

    i think am not able to form kernal object file from the c object file.
    please help me out in correcting the makefile

  2. #2
    try this Makefile

    obj-m += hello1.o
    KVER := $(shell uname -r)
    PWD := $(shell pwd)
    	$(MAKE) -C /lib/modules/$(KVER)/build  M=$(PWD) modules

Posting Permissions

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