Salut tout le monde.
J'ai récement installer Centos et je suis débutante sur linux
J'ai un problème de reconnaissance des bibliothèque C avec mon programme, sachant que j'utilise make comme compilateur.
Voici mon code :
Code c : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61 #include <linux/module.h> #include <linux/kernel.h> # include <linux/sched.h> # include <linux/netlink.h> # include <net/sock.h> # include <net/net_namespace.h> # include <stdlib.h> #include <stdio.h> #include <sys/sendfile.h> # define NETLINK_NITRO 17 MODULE_LICENSE("GPL"); static struct sock *nl_sk = NULL; static void nl_data_ready (struct sk_buff *skb) { struct nlmsghdr *nlh = NULL; if(skb == NULL) { printk("skb is NULL \n"); return ; } nlh = (struct nlmsghdr *)skb->data; printk(KERN_INFO "%s: received netlink message payload: %s\n", __FUNCTION__, (char *) NLMSG_DATA(nlh)); } static void netlink_test() { nl_sk = netlink_kernel_create(&init_net,NETLINK_NITRO,0, nl_data_ready,NULL, THIS_MODULE); } static int __init my_module_init(void) { printk(KERN_INFO "Initializing Netlink Socket"); netlink_test(); return 0; } static void __exit my_module_exit(void) { ssize_t sendfile(int fichier , int sock_fd , off_t * offset, size_t count); { FILE* fichier = NULL; fichier = fopen("/home/ahlem/GPL.odt" , "r+"); if (fichier != NULL) return 0 ;// On lit et on écrit dans le fichier fclose(fichier) ; //le fichier doit être fermé si l'ouverture a réussi ie si fichier != NULL return ; } } module_init(my_module_init); module_exit(my_module_exit);
Et voilà les erreurs :
Il n'arrive pas à trouver les bibliothèques malgré qu'ils sont déjà installer, je suis sur, car j'ai déjà les utilisé dans un autre programme et ça marche bien sans erreurs mais avec le compilateur gcc.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 [root@Ahlem bin]# make make -C /lib/modules/2.6.32-220.7.1.el6.x86_64/build M=/home/ahlem/bin modules make[1]: entrant dans le répertoire « /usr/src/kernels/2.6.32-220.13.1.el6.centos.plus.x86_64 » CC [M] /home/ahlem/bin/prgfile.o /home/ahlem/bin/prgfile.c:8:21: erreur: stdlib.h : Aucun fichier ou dossier de ce type /home/ahlem/bin/prgfile.c:9:19: erreur: stdio.h : Aucun fichier ou dossier de ce type /home/ahlem/bin/prgfile.c:10:27: erreur: sys/sendfile.h : Aucun fichier ou dossier de ce type /home/ahlem/bin/prgfile.c:32: attention : function declaration isnt a prototype /home/ahlem/bin/prgfile.c: In function my_module_exit: /home/ahlem/bin/prgfile.c:49: erreur: FILE undeclared (first use in this function) /home/ahlem/bin/prgfile.c:49: erreur: (Each undeclared identifier is reported only once /home/ahlem/bin/prgfile.c:49: erreur: for each function it appears in.) /home/ahlem/bin/prgfile.c:49: erreur: fichier undeclared (first use in this function) /home/ahlem/bin/prgfile.c:51: erreur: implicit declaration of function fopen /home/ahlem/bin/prgfile.c:54: attention : return with a value, in function returning void /home/ahlem/bin/prgfile.c:56: erreur: implicit declaration of function fclose make[2]: *** [/home/ahlem/bin/prgfile.o] Erreur 1 make[1]: *** [_module_/home/ahlem/bin] Erreur 2 make[1]: quittant le répertoire « /usr/src/kernels/2.6.32-220.13.1.el6.centos.plus.x86_64 » make: *** [all] Erreur 2
Quelqu'un peut m'informer s'il vous plaît ? Merci d'avance.
Partager