I am writing a simple device driver in C in Ubuntu 8.04 and when I compile my C code:
#define MODULE
#include <linux/module.h>
int init_module(void) { printk("<1>Hello, world\n"); return 0; }
void cleanup_module(void) { printk("<1>Goodbye cruel world\n"); }
it gives the error: "Module.h not found", to handle which I searched for module.h and copied the entire include directory into the include directory used by gcc, but things still don't work and now the following errors have come up:
In file included from /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:9, from example1.c:2: /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/list.h:995:2: warning: #warning "don't include kernel headers in userspace" In file included from /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:12, from example1.c:2: /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/cache.h:5:23: error: asm/cache.h: No such file or directory In file included from /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:18, from example1.c:2: /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/marker.h:103: error: expected declaration specifiers or ‘...’ before numeric constant /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/marker.h:103: error: expected declaration specifiers or ‘...’ before numeric constant /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/marker.h: In function ‘printf’: /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/marker.h:103: error: expected declaration specifiers before ‘__mark_check_format’ /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/marker.h:107: error: storage class specified for parameter ‘__mark_empty_function’ /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/marker.h:114: error: storage class specified for parameter ‘marker_probe_register’ /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/marker.h:119: error: storage class specified for parameter ‘marker_probe_unregister’ /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/marker.h:123: error: storage class specified for parameter ‘marker_probe_unregister_private_data’ /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/marker.h:125: error: storage class specified for parameter ‘marker_arm’ /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/marker.h:126: error: storage class specified for parameter ‘marker_disarm’ /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/marker.h:127: error: storage class specified for parameter ‘marker_get_private_data’ In file included from example1.c:2: /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:19:23: error: asm/local.h: No such file or directory /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:21:24: error: asm/module.h: No such file or directory In file included from example1.c:2: /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:48: error: field ‘attr’ has incomplete type /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:59: error: field ‘kobj’ has incomplete type /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:65: error: storage class specified for parameter ‘init_module’ /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:66: error: storage class specified for parameter ‘cleanup_module’ /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:84: error: storage class specified for parameter ‘__this_module’ /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:477: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute’ before ‘{’ token /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:483: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘{’ token /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:489: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘{’ token /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:494: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘{’ token /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:504: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘{’ token /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:508: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘{’ token /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:513: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘{’ token /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:523: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘{’ token /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:528: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘{’ token /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:533: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘{’ token /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:540: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘{’ token /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:545: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘{’ token /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:550: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘{’ token /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:556: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘{’ token /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:563: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘{’ token /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:568: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘{’ token /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:589: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘{’ token /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:596: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘{’ token /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:601: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘{’ token /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:606: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘{’ token /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:618: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘{’ token /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:621: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘{’ token example1.c:3: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘{’ token example1.c:4: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘{’ token /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:163: error: declaration for parameter ‘search_exception_tables’ but no such parameter /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:84: error: parameter ‘__this_module’ has incomplete type /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:84: error: declaration for parameter ‘__this_module’ but no such parameter /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:77: error: declaration for parameter ‘sort_main_extable’ but no such parameter /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:76: error: declaration for parameter ‘sort_extable’ but no such parameter /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:74: error: declaration for parameter ‘search_extable’ but no such parameter /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:66: error: declaration for parameter ‘cleanup_module’ but no such parameter /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/module.h:65: error: declaration for parameter ‘init_module’ but no such parameter /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/marker.h:127: error: declaration for parameter ‘marker_get_private_data’ but no such parameter /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/marker.h:126: error: declaration for parameter ‘marker_disarm’ but no such parameter /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/marker.h:125: error: declaration for parameter ‘marker_arm’ but no such parameter /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/marker.h:123: error: declaration for parameter ‘marker_probe_unregister_private_data’ but no such parameter /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/marker.h:119: error: declaration for parameter ‘marker_probe_unregister’ but no such parameter /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/marker.h:114: error: declaration for parameter ‘marker_probe_register’ but no such parameter /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include/linux/marker.h:107: error: declaration for parameter ‘__mark_empty_function’ but no such parameter example1.c:4: error: expected ‘{’ at end of input
and though I have used my root priviliges which are definitely not helping in this case.
Please help so that I can continue working.
I have searched over the net but haven't find any suitable answer except for compiling the kernel about which I don't know how to proceed, And if there's no solution then should I change my Linux Distribution??
Thanks in advance.