Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

[Module]Erreurs de compilation skull

2 réponses
Avatar
Emmanuel Delahaye
Bonjour,

Sur ma machine

* PC/x86
* kernel 2.6
* Mandrake 10.1


impossible de compiler ceci (skull)

/* com_driver.c */
#include <linux/module.h>

int __entry com_init_module (void)
{
printk( KERN_DEBUG "Module com init\n" );
return 0;
}

int __exit com_cleanup_module (void)
{
printk( KERN_DEBUG "Module com exit\n" );
return 0;
}

Le makefile est

# generer un module pour Linux 2.6 sur i586

CFLAG1 = -W -Wall -O2
CFLAG2 = -D__KERNEL__ -DMODULE
CFLAG3 =

CFLAGS = $(CFLAG1) $(CFLAG2) $(CFLAG3)

# cible finale
all : com.o

# fichier source
com.o : com.c
gcc $(CFLAGS) -c com.c -o com.o

Ca génère des tas d'erreurs comme

[edelahaye@localhost com]$ make
gcc -W -Wall -O2 -D__KERNEL__ -DMODULE -c com.c -o com.o
In file included from /usr/include/linux/sched.h:14,
from /usr/include/linux/module.h:9,
from com.c:2:
/usr/include/linux/cpumask.h:80: error: syntax error before
"DECLARE_BITMAP"
/usr/include/linux/cpumask.h:81: error: syntax error before
"_unused_cpumask_arg_"
/usr/include/linux/cpumask.h:84: error: syntax error before '*' token
/usr/include/linux/cpumask.h: In function `__cpu_set':
/usr/include/linux/cpumask.h:86: error: `cpu' undeclared (first use in
this function)
/usr/include/linux/cpumask.h:86: error: (Each undeclared identifier is
reported only once
/usr/include/linux/cpumask.h:86: error: for each function it appears
in.)
/usr/include/linux/cpumask.h:86: error: `dstp' undeclared (first use in
this function)
<...>


Il doit manquer des définitions de macros (-Dxxx), mais lesquelles... ?

Merci de m'aider.

Emmanuel

--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html

.sig under repair

2 réponses

Avatar
Thomas Labourdette
Emmanuel Delahaye a écrit le Mardi 17 Mai 2005 20:21 :



impossible de compiler ceci (skull)


Ta doc est obsolète

/* com_driver.c */
#include <linux/module.h>

int __entry com_init_module (void)


int init_module(void)

{
printk( KERN_DEBUG "Module com initn" );
return 0;
}



void cleanup_module (void)
{
printk( KERN_DEBUG "Module com exitn" );
return 0;


on supprime le return

}

Le makefile est


Cela c'est simplifié

obj-m += com.o

Par contre la compilation c'est (sur une seule ligne) :

make -C /repertoire/des/sources/du/noyeau/2.6/
SUBDIRS=/repertoire/de/test/source module

Ce qui donne avec ton fichier :
:~/test$ make -C /usr/src/kernel-source-2.6.11 SUBDIRS=$PWD
modules
make: Entering directory `/usr/src/kernel-source-2.6.11'
CC [M] /home/tlabourdette/test/com.o
Building modules, stage 2.
MODPOST
CC /home/tlabourdette/test/com.mod.o
LD [M] /home/tlabourdette/test/com.ko
make: Leaving directory `/usr/src/kernel-source-2.6.11'

Tu devrais jeter un oeil à la doc suivante :
http://tldp.org/LDP/lkmpg/2.6/html/index.html

Bon courage.

@+
--
Alphonsine DUTRAIN-POURDIRORVOIR (signature aléatoire)
Inscriptions relevées sur divers produits de grande consommation :
Sur un Pudding Marks & Spencer : "Le produit sera chaud après avoir
été réchauffé"

Avatar
Emmanuel Delahaye
Thomas Labourdette wrote on 18/05/05 :
Emmanuel Delahaye a écrit le Mardi 17 Mai 2005 20:21 :

impossible de compiler ceci (skull)


Ta doc est obsolète


<...>

Ok, merci beaucoup. En fait, en plus des quelques bêtises de mon code
source, j'avais pas installé les sources!

Tu devrais jeter un oeil à la doc suivante :
http://tldp.org/LDP/lkmpg/2.6/html/index.html


Je vais étudier ce lien en détail.

Encore merci.

--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html

"There are 10 types of people in the world today;
those that understand binary, and those that dont."