Compiling Kernel Modules in Ubuntu 10.10

Discussion in 'Linux' started by lionaneesh, Jan 7, 2011.

  1. lionaneesh

    lionaneesh Active Member

    Joined:
    Mar 21, 2010
    Messages:
    848
    Likes Received:
    224
    Trophy Points:
    43
    Occupation:
    Student
    Location:
    India
    After Being Fully Enthusiastic and ready to make my own Kernel Modules I started the work to be done to get started into kernel programming...
    I have managed to successfully compile my own kernel...But while compiling my modules
    After trying continuously for about 4-5 hrs....... I am totally frustrated and Asking for your help!!!

    System Information :-

    Linux Version : Ubuntu 10.10 i386
    Kernel Version : 2.6.32.26

    The Problem :-

    The main problem is the make part...
    I have a hello-1.c code from http://www.faqs.org/docs/kernel/x204.html
    Code:
    /*  hello-1.c - The simplest kernel module.
    
     */
    
    #include <linux/module.h>  /* Needed by all modules */
    
    #include <linux/kernel.h>  /* Needed for KERN_ALERT */
    
    int init_module(void)
    
    {
    
       printk("<1>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_ALERT "Goodbye world 1.\n");
    
    }
    
    and a Makefile is from different source as the above source provides makefile for kernel 2.4
    Code:
    ifneq ($(KERNELRELEASE),)
    
    # We were called by kbuild
    
    
    
    obj-m += target.o
    
    
    
    else  # We were called from command line
    
    
    
    KDIR := /lib/modules/$(shell uname -r)/build
    
    #KDIR := /home/cynove/src/kernel/linux-source-2.6.31
    
    PWD  := $(shell pwd)
    
    
    
    default:
    
    	@echo '    Building target module 2.6 kernel.'
    
    	@echo '    PLEASE IGNORE THE "Overriding SUBDIRS" WARNING'
    
    	$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
    
    
    
    install:
    
    	./do_install.sh *.ko
    
    
    
    endif  # End kbuild check
    
    ######################### Version independent targets ##########################
    
    
    
    clean:
    
    	rm -f -r *.o *.ko .*cmd .tmp* core *.i
    
    I am constantly getting the same errors :-
    Code:
        Building target module 2.6 kernel.
    
        PLEASE IGNORE THE "Overriding SUBDIRS" WARNING
    
    make -C /lib/modules/2.6.32.26+drm33.12-explict-hax0r/build SUBDIRS=/home/aneesh/semtex modules
    
    make[1]: Entering directory `/home/aneesh/source/linux-source-2.6.32'
    
    make[2]: *** No rule to make target `/home/aneesh/semtex/target.c', needed by `/home/aneesh/semtex/target.o'.  Stop.
    
    make[1]: *** [_module_/home/aneesh/semtex] Error 2
    
    make[1]: Leaving directory `/home/aneesh/source/linux-source-2.6.32'
    
    make: *** [default] Error 2
    
    
    I am totally discouraged and frustrated by not getting results after trying so hard...
    I checked the Makefile and seems it all is right ….
    Really I am unable to get a clue what's wrong...
    I thing maybe something is missing... But what?Where?Why?

    Thanks in Advance

    Your's faithfully
    `uname -r`
     
  2. lionaneesh

    lionaneesh Active Member

    Joined:
    Mar 21, 2010
    Messages:
    848
    Likes Received:
    224
    Trophy Points:
    43
    Occupation:
    Student
    Location:
    India
    Hey ...
    After spending some more time with my cool mind i figured out the problem..

    There was a issue with this silly Makefile ....
    Code:
    ifneq ($(KERNELRELEASE),)
    
    # We were called by kbuild
    
    
    
    obj-m += [COLOR="Red"]hello-1.c[/COLOR]
    
    
    
    else  # We were called from command line
    
    
    
    KDIR := /lib/modules/$(shell uname -r)/build
    
    #KDIR := /home/cynove/src/kernel/linux-source-2.6.31
    
    PWD  := $(shell pwd)
    
    
    
    default:
    
    	@echo '    Building target module 2.6 kernel.'
    
    	@echo '    PLEASE IGNORE THE "Overriding SUBDIRS" WARNING'
    
    	$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
    
    
    
    install:
    
    	./do_install.sh *.ko
    
    
    
    endif  # End kbuild check
    
    ######################### Version independent targets ##########################
    
    
    
    clean:
    
    	rm -f -r *.o *.ko .*cmd .tmp* core *.i
    
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice