Forum des développeurs  

Le forum de référence en programmation et développement. Articles, cours et tutoriels du débutant au chef de projet et DBA confirmé.
Précédent   Forum des développeurs > Hardware, Systèmes et Logiciels > Linux > Distributions > Debian

Debian Vos questions sur la distribution Debian

Réponse
 
Outils de la discussion
Vieux 31/10/2008, 21h30   #1 (permalink)
Nouveau membre du Club
 
Date d'inscription: décembre 2007
Messages: 59
Envoyer un message via MSN à rufa11
Par défaut programmation module kernel

Bonjour, j'ai compilé un programme kernel qui affiche hello word:

hello.c
* Copyright (C) 1998 by Ori Pomerantz
*
* "Hello, world" - the kernel module version.
*/
/* The necessary header files */
/* Standard in kernel modules */
#include <linux/kernel.h> /* We’re doing kernel work */
#include <linux/module.h> /* Specifically, a module */
/* Deal with CONFIG_MODVERSIONS */
#if CONFIG_MODVERSIONS==1
#define MODVERSIONS
#include <linux/modversions.h>
#endif
/* Initialize the module */
int init_module()
{
printk("Hello, world - this is the kernel speaking\n");
/* If we return a non zero value, it means that
* init_module failed and the kernel module
* can’t be loaded */
return 0;
}
/* Cleanup - undid whatever init_module did */
void cleanup_module()
{
printk("Short is the life of a kernel module\n");
}

les erreurs suivantes son apparus:

abdelkader@abdelkader:~$ make hello
cc hello.c -o hello
In file included from /usr/include/asm-i486/local.h:4,


from /usr/include/asm/local.h:8,


from /usr/include/linux/module.h:20,


from hello.c:2:
/usr/include/linux/percpu.h: In function ‘__alloc_percpu’:
/usr/include/linux/percpu.h:44: error: ‘GFP_KERNEL’ undeclared (first use in this function)
/usr/include/linux/percpu.h:44: error: (Each undeclared identifier is reported only once
/usr/include/linux/percpu.h:44: error: for each function it appears in.)
In file included from /usr/include/asm/module.h:8,

from /usr/include/linux/module.h:22,

from hello.c:2:
/usr/include/asm-i486/module.h:60:2: error: #error unknown processor family
In file included
from hello.c:2:
/usr/include/linux/module.h: At top level:
/usr/include/linux/module.h:49: error: field ‘attr’ has incomplete type
/usr/include/linux/module.h:60: error: field ‘kobj’ has incomplete type
make: *** [hello] Erreur 1

le fichier make file :

# Makefile for a basic kernel module
CC=gcc
MODCFLAGS := -Wall -DMODULE -D__KERNEL__ -DLINUX
hello.o: hello.c /usr/include/linux/version.h
$(CC) $(MODCFLAGS) -c hello.c
echo insmod hello.o to turn it on
echo rmmod hello to turn if off
echo
echo X and kernel programming do not mix.
echo Do the insmod and rmmod from outside X.


la distribution est debian version 4.0.
svp je veut comprend les erreurs pour que je puisse les résoudre.
rufa11 est déconnecté   Envoyer un message privé Réponse avec citation
Vieux 31/10/2008, 23h10   #2 (permalink)
Nouveau membre du Club
 
Date d'inscription: décembre 2007
Messages: 59
Envoyer un message via MSN à rufa11
Par défaut

salut,on ma dit le kernel a beacoup changer depuis 1999 (la date de ce programme)alors j'ai compilé avec la version du kernel 2.6 "http://www.tldp.org/LDP/lkmpg/"
le programme est :

/*

* hello-1.c - The simplest kernel module.

*/
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_INFO */

int init_module(void)
{
printk(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");
}
mais dans la compilation avec make les erreurs:
cc hello.c -o hello
In

file included from /usr/include/asm-i486/local.h:4,

from /usr/include/asm/local.h:8,

from /usr/include/linux/module.h:20,

from hello.c:2:
/usr/include/linux/percpu.h: In function ‘__alloc_percpu’:

/usr/include/linux/percpu.h:44: error: ‘GFP_KERNEL’ undeclared (first use in this function)
/usr/include/linux/percpu.h:44: error: (Each undeclared identifier is reported only once
/usr/include/linux/percpu.h:44: error: for each function it appears in.)

In file included from
/usr/include/asm/module.h:8,

from /usr/include/linux/module.h:22,

from hello.c:2:
/usr/include/asm-i486/module.h:60:2: error: #error unknown processor family
In file included from hello.c:2:
/usr/include/linux/module.h: At top level:

/usr/include/linux/module.h:49: error: field ‘attr’ has incomplete type

/usr/include/linux/module.h:60: error: field ‘kobj’ has incomplete type

hello.c: In function ‘init_module’:
hello.c:6: error: ‘KERN_INFO’ undeclared (first use in this function)

hello.c:6: error: expected ‘)’ before string constant

hello.c: In function ‘cleanup_module’:

hello.c:12: error: ‘KERN_INFO’ undeclared (first use in this function)

hello.c:12: error: expected ‘)’ before string constant

hello.c:13:2: warning: no newline at end of file

make: *** [hello] Erreur 1

alors j'ai supprimé KERN INFO alors le résultat est :

cc hello.c -o hello

In file included from
/usr/include/asm-i486/local.h:4,

from /usr/include/asm/local.h:8,
from /usr/include/linux/module.h:20,
from hello.c:2:
/usr/include/linux/percpu.h: In function ‘__alloc_percpu’:

/usr/include/linux/percpu.h:44: error: ‘GFP_KERNEL’ undeclared (first use in this function)
/usr/include/linux/percpu.h:44: error: (Each undeclared identifier is reported only once
/usr/include/linux/percpu.h:44: error: for each function it appears in.)

In file included from
/usr/include/asm/module.h:8,

from /usr/include/linux/module.h:22,

from hello.c:2:
/usr/include/asm-i486/module.h:60:2: error: #error unknown processor family

In file included from
hello.c:2:
/usr/include/linux/module.h: At top level:

/usr/include/linux/module.h:49: error: field ‘attr’ has incomplete type

/usr/include/linux/module.h:60: error: field ‘kobj’ has incomplete type

hello.c:13:2: warning: no newline at end of file

make: *** [hello] Erreur 1

le fichier Makefile est :
obj-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

svp aidai moi c'est pour mon projet de fin d'étude,merci d'avance.
rufa11 est déconnecté   Envoyer un message privé Réponse avec citation
Vieux 01/11/2008, 00h14   #3 (permalink)
Nouveau membre du Club
 
Date d'inscription: décembre 2007
Messages: 59
Envoyer un message via MSN à rufa11
Par défaut

pour: hello.c:13:2: warning: no newline at end of file
c'est résolu,il suffit d'aller a la dernière ligne du programme et d'appuyer sur entre,il reste le plus difficile.
rufa11 est déconnecté   Envoyer un message privé Réponse avec citation
NEWS LINUX PROFESSIONNELFAQ LINUXTUTORIELS LINUXLIVRES LINUXLINUX TVUNIXGTK+QtAPACHE

Réponse

Précédent   Forum des développeurs > Hardware, Systèmes et Logiciels > Linux > Distributions > Debian



Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are non
Pingbacks are non
Refbacks are non
Navigation rapide


Fuseau horaire GMT +1. Il est actuellement 01h09.


Publiez vos articles, tutoriels et cours et rejoignez-nous dans l'équipe de rédaction du club d'entraide des développeurs francophones. Nous contacter