Results 1 to 6 of 6
Hello everyone,
I am writing a very simple kernel module that is available on the net.
But while compiling it I am getting the error for include files.
Can anyone ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 03-16-2010 #1Just Joined!
- Join Date
- Mar 2010
- Posts
- 3
Kernel Module
Hello everyone,
I am writing a very simple kernel module that is available on the net.
But while compiling it I am getting the error for include files.
Can anyone please tell me what is the procedure for include files for kernel modules.
It would be really helpful if I get an example or a link I can get to learn about include files and kernel module programming starting from basics.
- 03-16-2010 #2Just Joined!
- Join Date
- Mar 2010
- Posts
- 3
The Module I got only have printk in the init_module() and that in cleanup_module().
It has a include file named uaccess.h
It is not getting this file.
I dont know where exactly the kernel module needs its include files.
Is there any specific location.
I am compiling it using gcc.
and then using a Makefile for making a .ko .
Which I suppose then will be inserted as a module using "insmod"
and removed using "rmmod"
If there is any other way to do it please tell me.
I am reading Linux Kernel Module Programming .pdf O'reilly 2nd edition.
- 03-16-2010 #3Just Joined!
- Join Date
- Mar 2010
- Posts
- 3
the code looks something like this
I dont know why it requires that uaccess.h
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/uaccess.h>
int init_module(void)
{
printk(KERN_INFO "init_module() called\n");
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO "cleanup_module() called\n");
}
I tried to locate uaccess.h but not in linux named folder
Makefile looks like this
obj-m += hello.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
- 03-16-2010 #4
Could you please use code tags so that we can see if the formating of your make file is correct..
Also if you open a terminal and su root and type
cd /lib/modules/$(uname -r)/build
What do you get?Make mine Arch Linux
- 03-23-2010 #5Just Joined!
- Join Date
- Oct 2009
- Posts
- 85
Do you have the linux source in the given folder ?????
- 03-23-2010 #6
here is the MAkefile example(pls notice the usage of tab if you have provided 8 spaces that would be wrong)
save it & then runCode:obj-m += usb-skeleton.o all: <tab>make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules clean: <tab>make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
try compiling your code without writing include<uaccess.h> line this could be a user defined header by the authorCode:#make


Reply With Quote
