Re: insmod error on FC2?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



littertiger wrote:
> Hello,fedora-list
> 
> Source:
> #define MODULE
> #include <linux/module.h>
> int init_module(void) {printk("<1>Hello,world\n");return 0;}
> void cleanup_module(void) {printk("<1>Goodbye cruel world\n");}
> 
> It is the first demo of book "The linux device driver". then,
> gcc -c hello.c
> insmod ./hello.o
> then an error occured:
> insmod error inserting "hello.o": -l Invalid module fromat
> 

You can't compile a kernel module this way.

>From the mail I just sent to the list a few seconds ago:

The Makefile
----------

obj-m    := your-module.o

KDIR    := /lib/modules/$(shell uname -r)/build
PWD    := $(shell pwd)

default:
    $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules

----------

You have your-module.c and the Makefile in the current directory,
just issue "make" and the your-module.ko is built.

install it with this: (I have a install.sh script for that)

#!/bin/sh
install -m 644 your-module.ko /lib/modules/`uname -r`/kernel/drivers/your-module.ko
/sbin/depmod -a

(adjust the /lib/modules path according to your needs)

Now make a

# modprobe your-module

and off the fun goes ;-)

Cheers,
Hannes.




[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux