Bonsoir,
J'essai de suivre le tuto suivant : http://broux.developpez.com/articles/c/driver-c-linux/

Donc 1ere chose, je tente de compiler le code d'exemple et c'est là que mon premier obstacle apparait...

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
#define MODULE
#include <linux/module.h>
#include <linux/init.h>
 
static int __init mon_module_init(void)
{
	printk(KERN_DEBUG "Hello World !\n");
	return 0;
}
 
static void __exit mon_module_cleanup(void)
{
    printk(KERN_DEBUG "Goodbye World!\n");
}
 
module_init(mon_module_init);
module_exit(mon_module_cleanup);
Ma commande pour compiler le tout :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
gcc -c -I/usr/src/linux-headers-2.6.17-10-386/include/ module.c
Et le résultat... Je dois avouer que je suis un peu perdu... Les erreurs viennent de fichiers systèmes on dirait :/

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
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
In file included from /usr/src/linux-headers-2.6.17-10-386/include/linux/bitops.h:9,
                 from /usr/src/linux-headers-2.6.17-10-386/include/linux/thread_info.h:20,
                 from /usr/src/linux-headers-2.6.17-10-386/include/linux/preempt.h:9,
                 from /usr/src/linux-headers-2.6.17-10-386/include/linux/spinlock.h:49,
                 from /usr/src/linux-headers-2.6.17-10-386/include/linux/module.h:10,
                 from module.c:2:
/usr/src/linux-headers-2.6.17-10-386/include/asm/bitops.h:244: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘int’
In file included from /usr/src/linux-headers-2.6.17-10-386/include/linux/spinlock.h:56,
                 from /usr/src/linux-headers-2.6.17-10-386/include/linux/module.h:10,
                 from module.c:2:
/usr/src/linux-headers-2.6.17-10-386/include/asm/system.h:307: error: expected declaration specifiers or ‘...’ before ‘u8’
/usr/src/linux-headers-2.6.17-10-386/include/asm/system.h:307: error: expected declaration specifiers or ‘...’ before ‘u8’
/usr/src/linux-headers-2.6.17-10-386/include/asm/system.h:308: error: expected declaration specifiers or ‘...’ before ‘u16’
/usr/src/linux-headers-2.6.17-10-386/include/asm/system.h:308: error: expected declaration specifiers or ‘...’ before ‘u16’
/usr/src/linux-headers-2.6.17-10-386/include/asm/system.h:309: error: expected declaration specifiers or ‘...’ before ‘u32’
/usr/src/linux-headers-2.6.17-10-386/include/asm/system.h:309: error: expected declaration specifiers or ‘...’ before ‘u32’
/usr/src/linux-headers-2.6.17-10-386/include/asm/system.h: In function ‘cmpxchg_386’:
/usr/src/linux-headers-2.6.17-10-386/include/asm/system.h:316: error: too many arguments to function ‘cmpxchg_386_u8’
/usr/src/linux-headers-2.6.17-10-386/include/asm/system.h:318: error: too many arguments to function ‘cmpxchg_386_u16’
/usr/src/linux-headers-2.6.17-10-386/include/asm/system.h:320: error: too many arguments to function ‘cmpxchg_386_u32’
In file included from /usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:86,
                 from /usr/src/linux-headers-2.6.17-10-386/include/asm/processor.h:22,
                 from /usr/src/linux-headers-2.6.17-10-386/include/asm/atomic.h:5,
                 from /usr/src/linux-headers-2.6.17-10-386/include/linux/spinlock.h:230,
                 from /usr/src/linux-headers-2.6.17-10-386/include/linux/module.h:10,
                 from module.c:2:
/usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h: In function ‘bitmap_zero’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:128: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
/usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:128: error: (Each undeclared identifier is reported only once
/usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:128: error: for each function it appears in.)
/usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:132: warning: incompatible implicit declaration of built-in function ‘memset’
/usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h: In function ‘bitmap_fill’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:141: warning: incompatible implicit declaration of built-in function ‘memset’
/usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:143: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
/usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h: In function ‘bitmap_copy’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:149: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
/usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:153: warning: incompatible implicit declaration of built-in function ‘memcpy’
/usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h: In function ‘bitmap_and’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:160: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
/usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h: In function ‘bitmap_or’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:169: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
/usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h: In function ‘bitmap_xor’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:178: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
/usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h: In function ‘bitmap_andnot’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:187: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
/usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h: In function ‘bitmap_complement’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:196: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
/usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h: In function ‘bitmap_equal’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:205: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
/usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h: In function ‘bitmap_intersects’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:214: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
/usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h: In function ‘bitmap_subset’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:223: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
/usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h: In function ‘bitmap_empty’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:231: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
/usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h: In function ‘bitmap_full’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:239: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
/usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h: In function ‘bitmap_shift_right’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:253: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
/usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h: In function ‘bitmap_shift_left’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/bitmap.h:262: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
In file included from /usr/src/linux-headers-2.6.17-10-386/include/asm/processor.h:22,
                 from /usr/src/linux-headers-2.6.17-10-386/include/asm/atomic.h:5,
                 from /usr/src/linux-headers-2.6.17-10-386/include/linux/spinlock.h:230,
                 from /usr/src/linux-headers-2.6.17-10-386/include/linux/module.h:10,
                 from module.c:2:
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: At top level:
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:88: error: expected specifier-qualifier-list before ‘DECLARE_BITMAP’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpu_set’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:94: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpu_clear’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:100: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpus_setall’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:106: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpus_clear’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:112: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpu_test_and_set’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:121: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpus_and’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:128: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:128: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:128: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpus_or’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:135: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:135: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:135: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpus_xor’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:142: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:142: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:142: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpus_andnot’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:150: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:150: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:150: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpus_complement’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:157: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:157: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpus_equal’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:164: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:164: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpus_intersects’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:171: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:171: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpus_subset’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:178: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:178: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpus_empty’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:184: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpus_full’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:190: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpus_weight’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:196: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpus_shift_right’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:204: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:204: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpus_shift_left’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:212: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:212: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpumask_scnprintf’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:273: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpumask_parse’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:281: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpulist_scnprintf’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:289: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpulist_parse’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:295: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpu_remap’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:303: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:303: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h: In function ‘__cpus_remap’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:311: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:311: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:311: error: ‘cpumask_t’ has no member named ‘bits’
/usr/src/linux-headers-2.6.17-10-386/include/linux/cpumask.h:311: error: ‘cpumask_t’ has no member named ‘bits’
In file included from /usr/src/linux-headers-2.6.17-10-386/include/asm/atomic.h:5,
                 from /usr/src/linux-headers-2.6.17-10-386/include/linux/spinlock.h:230,
                 from /usr/src/linux-headers-2.6.17-10-386/include/linux/module.h:10,
                 from module.c:2:
/usr/src/linux-headers-2.6.17-10-386/include/asm/processor.h: At top level:
/usr/src/linux-headers-2.6.17-10-386/include/asm/processor.h:76: error: ‘CONFIG_X86_L1_CACHE_SHIFT’ undeclared here (not in a function)
/usr/src/linux-headers-2.6.17-10-386/include/asm/processor.h:76: error: requested alignment is not a constant
In file included from /usr/src/linux-headers-2.6.17-10-386/include/linux/module.h:11,
                 from module.c:2:
/usr/src/linux-headers-2.6.17-10-386/include/linux/list.h:838:2: warning: #warning "don't include kernel headers in userspace"
In file included from /usr/src/linux-headers-2.6.17-10-386/include/asm/local.h:4,
                 from /usr/src/linux-headers-2.6.17-10-386/include/linux/module.h:20,
                 from module.c:2:
/usr/src/linux-headers-2.6.17-10-386/include/linux/percpu.h: In function ‘__alloc_percpu’:
/usr/src/linux-headers-2.6.17-10-386/include/linux/percpu.h:44: error: ‘GFP_KERNEL’ undeclared (first use in this function)
/usr/src/linux-headers-2.6.17-10-386/include/linux/percpu.h:44: warning: initialization makes pointer from integer without a cast
/usr/src/linux-headers-2.6.17-10-386/include/linux/percpu.h:46: warning: incompatible implicit declaration of built-in function ‘memset’
In file included from /usr/src/linux-headers-2.6.17-10-386/include/linux/module.h:22,
                 from module.c:2:
/usr/src/linux-headers-2.6.17-10-386/include/asm/module.h:60:2: error: #error unknown processor family
In file included from module.c:2:
/usr/src/linux-headers-2.6.17-10-386/include/linux/module.h: At top level:
/usr/src/linux-headers-2.6.17-10-386/include/linux/module.h:49: error: field ‘attr’ has incomplete type
/usr/src/linux-headers-2.6.17-10-386/include/linux/module.h:60: error: field ‘kobj’ has incomplete type
/usr/src/linux-headers-2.6.17-10-386/include/linux/module.h:561: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘inter_module_register’
/usr/src/linux-headers-2.6.17-10-386/include/linux/module.h:563: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘inter_module_unregister’
/usr/src/linux-headers-2.6.17-10-386/include/linux/module.h:564: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘inter_module_get_request’
/usr/src/linux-headers-2.6.17-10-386/include/linux/module.h:566: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘inter_module_put’
module.c: In function ‘mon_module_init’:
module.c:7: error: ‘KERN_DEBUG’ undeclared (first use in this function)
module.c:7: error: expected ‘)’ before string constant
module.c: In function ‘mon_module_cleanup’:
module.c:13: error: ‘KERN_DEBUG’ undeclared (first use in this function)
module.c:13: error: expected ‘)’ before string constant
Merci pour votre aide, remarques ou suggestion de tout arrêter

Edit : Ptite précision, je suis sous Ubuntu 6.10 !