FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian User

 
 
LinkBack Thread Tools
 
Old 01-08-2009, 07:35 AM
Tzafrir Cohen
 
Default compiling module

On Thu, Jan 08, 2009 at 08:58:20AM +0100, Abdelkader Belahcene wrote:
> Hi,
> I have problem to compile a small module example here is hello.c
>
> #include <linux/kernel.h>
> #include <linux/module.h>
>
> int init_module(){
> printk(KERN_DEBUG "Hello Kernel");
> return 0;
> }
> void cleanup_module(){
> printk(KERN_DEBUG "Good Bye Kernel");
> }
>
> I compile it with the command
> gcc -D__KERNEL__ -I/usr/src/linux/include/ -DMODULE -Wall -O2 -c hello.c
> -o hello.o

Wrong.

>
> uname -a gives
> Linux belaptop 2.6.26-1-686 #1 SMP Mon Dec 15 18:15:07 UTC 2008 i686
> GNU/Linux
>
> ls -l /usr/src
> lrwxrwxrwx 1 root src 19 2009-01-02 15:47 linux -> linux-source-2.6.26

Completely unnecessary

> drwxr-xr-x 18 root root 4096 2009-01-02 18:59 linux-headers-2.6.26-1-common
> drwxr-xr-x 3 root root 4096 2009-01-02 18:59 linux-kbuild-2.6.26
> drwxr-xr-x 21 root root 4096 2009-01-02 19:10 linux-source-2.6.26
> drwxr-xr-x 4 root root 4096 2009-01-06 09:54 linux-headers-2.6.26-1-686

This one is what you need.

# One-time setup:
echo 'obj-m := hello.o' > Kbuild

# Build command:
make -C /lib/modules/`uname -r`/build M=$PWD modules

# Install command (as root)
make -C /lib/modules/`uname -r`/build M=$PWD modules_install


/lib/modules/`uname -r`/build will in this case actually be
/usr/src/linux-headers-2.6.26-1-686 . But will also work with other
kernel versdions or if you install a self-built kernel that was built
on the same system

--
Tzafrir Cohen | tzafrir@jabber.org | VIM is
http://tzafrir.org.il | | a Mutt's
tzafrir@cohens.org.il | | best
ICQ# 16849754 | | friend


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 

Thread Tools




All times are GMT. The time now is 02:05 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org