Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to build .ko on linux

0 views
Skip to first unread message

kishore

unread,
Dec 29, 2005, 7:37:16 AM12/29/05
to
hi all,

In kernel version 2.6.9-16.EL, the loadable modules will have an
extension .ko rather than .o

My module name is pw_module.c, am using
gcc -c -Wall -O2 -DLINUX -DMODULE -D__KERNEL__
pw_module.c -I/lib/modules/`uname -r`/build/include
will result in pw_module.o

Its working fine on kernel version 2.4.18-14.
If i tried to load the same module on kernel version 2.6.9-16.EL,
resulting an "error : Invalid module format."

Can any one suggest, how to build .ko file on kernel version
2.6.9-16.EL .
Thanks, in advance.

regards,
kishore,packetware.


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/


Parag N(पराग़)

unread,
Dec 29, 2005, 7:54:23 AM12/29/05
to
Hi,
on 2.6 kernesl you can build module with following command
make -C /lib/modules/2.6.9-22.ELsmp/build M=/home/kishore
where its assumed that u have your kernel module C file under
/home/kishore and you can replace for whatever kernel you want to
bulid module instaed of 2.6.9-22.ELsmp
regards,
Parag.

Fawad Lateef

unread,
Dec 29, 2005, 8:29:55 AM12/29/05
to
On 12/29/05, kishore <kis...@packetwareindia.com> wrote:
>
> In kernel version 2.6.9-16.EL, the loadable modules will have an
> extension .ko rather than .o
>
> My module name is pw_module.c, am using
> gcc -c -Wall -O2 -DLINUX -DMODULE -D__KERNEL__
> pw_module.c -I/lib/modules/`uname -r`/build/include
> will result in pw_module.o
>
> Its working fine on kernel version 2.4.18-14.
> If i tried to load the same module on kernel version 2.6.9-16.EL,
> resulting an "error : Invalid module format."
>
> Can any one suggest, how to build .ko file on kernel version
> 2.6.9-16.EL .

The module build and loading system has been changed from kernel 2.5
series so the old build system of kernel 2.4.xx series wont work on
kernel 2.6.xx series. So the Makefile or make command you are using
wont work for 2.6.xx kernel and you have to compile kernel with
command :

make -C /lib/modules/<kernel_version>/build M=<your_source_path>

And for more details do look at driver-porting from 2.4 to 2.6 kernel
articles from the link http://lwn.net/Articles/driver-porting/ and
more specifically for makefiles take a look at article this
(http://lwn.net/Articles/21823/).

Also make sure that your module (code) will be for kernel 2.6.xx
series and 2.4.xx series wont run (or at-least not successfully) !

--
Fawad Lateef

MHD.Tayseer Alquoatli

unread,
Dec 30, 2005, 3:40:52 AM12/30/05
to

you can check the kbuild kernel documentation along with the articles pointed by Fawad
http://lxr.linux.no/source/Documentation/kbuild/
MHD.Tayseer

0 new messages