Installing Kernel Header Files
Hi all
I am using Ubuntu 9.04 with kernel version 2.6.28-11-generic.I want to compile the foll. file but i get <linux/slab.h> no such file or directory. mem_alloc.c #include<linux/slab.h> int main() { void * ptr; ptr=kmalloc(1024,GPF_KERNEL); return 0; } The kernel headers are installed in my system at /usr/src/linux-headers-2.6.28-11-generic/ directory. During compilation i specified as follows: gcc -I/usr/src/linux-headers-2.6.28-11-generic/include mem_alloc.c So can you tell me what might be the problem why gcc is unable to find the linux/slab.h header file? Thanks & Regards Ananth |
If the file /usr/src/linux-headers-2.6.28-11-generic/include/linux/slab.h or /usr/include/linux/slab.h exist, the error can be a bug in gcc/cpp, which is unprobable. Thus please check if one of the above files really exists and is readable.
I do not understand the meaning of your program. kmalloc() is a kernel function that is not available in userspace (it allocates kernel memory). An equivalent replacement is the function malloc() from malloc.h If you want to write a kernel module, then using a main() function is the wrong way to start with. In this case you should use: Code:
#include <linux/kernel.h> |
All times are GMT -5. The time now is 06:43 AM. |