![]() |
| 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é. | |||||||
|
|||||||
| Debian Vos questions sur la distribution Debian |
![]() |
|
|
Outils de la discussion |
|
|
#1 (permalink) |
|
Nouveau membre du Club
![]() |
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. |
|
|
|
|
|
#2 (permalink) |
|
Nouveau membre du Club
![]() |
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. |
|
|
|
|
![]() |
![]() |
||
programmation module kernel
|
||
| Outils de la discussion | |
|
|