can not compile hello module by gcc
Hey guys,
I am new to Linux drive programming. I am trying to learn it from a old book. The first example is to insert and remove a hello world module which is actually doing nothing. Here is the code of the module. Code:
#define MODULE According to the book. I should be able to compile it easily by typing the command: Code:
root# gcc -c hello.c this is the information about my system by command Code:
root# uname -r Could anyone helps out? And please tell the reason. Because i am new to this section. I have no idea how to read or write a make file. For me it is better to stick with the book. Figure out how to make the gcc works in this situation. Thanks for attention. |
Probably you have to install kernel headers. Which distribution are you using? In Ubuntu this is package named "linux-headers-generic".
|
Thanking you for replying.
I do have my headers under directory /usr/src/linux-headers-2.6.32-33-generic/include/linux/ |
Quote:
For a Kernel Module, you should create a Makefile; something like: Code:
obj-m := hello.o # Module Name is hello.c |
and also, the following red dots should be replaced by a TAB.
Makefile is TAB sensitive. Code:
obj-m := hello.o # Module Name is hello.c |
The headers : sudo apt-get install linux-libc-dev libc6-dev
.. will provide /usr/include/linux/<headers.h> But not module.h : There used to be /usr/include/linux/module.h for older kernels like 2.6.18. It's an old book. So you will have to point to /usr/src/linux-headers-2.6.32-33-generic/include/linux/ to use module.h . When a Makefile (post #4) is used, something like export CC="gcc -I/usr/src/linux-headers-2.6.32-33-generic/include/linux -I/usr/include" && make |
thank you, guys!
|
All times are GMT -5. The time now is 12:56 AM. |