Results 1 to 5 of 5

Thread: "hello world" module wont compile

  1. #1

    Default "hello world" module wont compile

    Same module install/works on FC6 machine.
    here are the out puts.
    I have installed
    1-linux-kernel-header
    2-kernel-source
    3-kernel-syms
    installed.

    MAke file
    Code:
    champ@linux-r9za:~/driver> ls
    Makefile  hello-1.c
    
    champ@linux-r9za:~/driver> cat Makefile 
    
    bj-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
    Hello world module, it complie runs on my FC6 machine.
    Code:
    champ@linux-r9za:~/driver> 
    champ@linux-r9za:~/driver> cat hello-1.c 
    #include <linux/module.h>	/* Needed by all modules */
    #include <linux/kernel.h>	/* Needed for KERN_INFO */
    
    int init_module(void)
    {
    	printjkk(KERN_INFO "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_INFO "Goodbye world 1.\n");
    }
    Build process:

    Code:
     make
    make -C /lib/modules/2.6.25.5-1.1-pae/build M=/home/champ modules
    make[1]: Entering directory `/usr/src/linux-2.6.25.5-1.1-obj/i386/pae'
    make[1]: *** No rule to make target `modules'.  Stop.
    make[1]: Leaving directory `/usr/src/linux-2.6.25.5-1.1-obj/i386/pae'
    make: *** [all] Error 2
    champ@linux-i5hb:~>

    I think I have every thing installed

    Code:
    p@linux-i5hb:~> rpm -qa | grep kernel
    linux-kernel-headers-2.6.25-8.1
    kernel-syms-2.6.25.11-0.1
    kernel-pae-2.6.25.5-1.1
    kernel-source-2.6.25.11-0.1
    champ@linux-i5hb:~>

    Any Ideas?

    Thanks.

  2. #2
    Join Date
    Jun 2008
    Location
    Oklahoma, US
    Posts
    822

    Default Re: "hello world" module wont compile


    Some initial observations:

    From hello-1.c:
    You have misspelled 'printk' as 'printjkk' in 'init_module',
    this will cause an error.
    You have an extra '{' just prior to 'void cleanup_module...',
    this will cause an error.
    From Makefile:
    You are missing the letter 'o' on the first line, this should
    read 'obj-m += hello-1.o'

    I have fixed these errors to facilitate my testing.

    After fixing the above errors, the module compiles cleanly.

    Make those changes as noted, should work for you.

    Loni

    --
    L R Nix
    lornix@lornix.com


  3. #3
    Join Date
    Jun 2008
    Location
    Oklahoma, US
    Posts
    822

    Default Re: "hello world" module wont compile


    As an afterthought, your errors you posted reminded me of a recent experience
    with a module...

    You *may* need to either reinstall kernel-source (which would reset some
    files and links needed) --OR-- execute the following: (as root)

    cd /usr/src/linux
    make cloneconfig
    make
    make modules_install
    make install

    and then reboot.

    This will recreate some necessary links and file within the linux and
    linux-obj directory structures needed to compile modules.

    Loni

    --
    L R Nix
    lornix@lornix.com


  4. #4

    Default Re: "hello world" module wont compile

    Thanks!
    recompiling kernel solved the issue.

    But new kernel have issue with ndiswrapper. After I install driver I do
    #modprobe ndiswraper
    It says driver module not found.

    Any idea?

    thanks.

  5. #5
    Join Date
    Jun 2008
    Location
    Oklahoma, US
    Posts
    822

    Default Re: "hello world" module wont compile

    On Sun, 17 Aug 2008 20:56:03 GMT
    aveceena <aveceena@no-mx.forums.opensuse.org> wrote:

    >
    > Thanks!
    > recompiling kernel solved the issue.
    >
    > But new kernel have issue with ndiswrapper. After I install driver I do
    >
    > #modprobe ndiswraper
    > It says driver module not found.
    >
    > Any idea?
    >
    > thanks.
    >
    >


    Well, you recompiled the kernel....

    Did you recompile the ndiswrapper module?

    They have to match... and old-kernel ndiswrapper doesn't match new-kernel.

    Yes, it's that picky. (You *can* make it less picky... but I doubt you'll
    need to recompile the kernel any more)

    Loni

    --
    L R Nix
    lornix@lornix.com


Posting Permissions

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