Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Please correct me if I'm missing something here. Thanks for your inputs.

Header included in code: #include <linux/slab.h>

Code snippet from my file that's asking for memory allocation using "kmalloc()":

/*
 * Initialize memory.
 */
 char* fs_ptr;
 fs_ptr = kmalloc((sizeof(char) * 20), GFP_USER);

 if (!fs_ptr) 
       printf("Error allocating space in memory.\n");
 }

Compile error:

$ make
gcc -g -Wall `pkg-config fuse --cflags` -c fs.c
fs.c:43:24: fatal error: linux/slab.h: No such file or directory
compilation terminated.

Ubuntu version Info.:

$ uname -a
Linux ubuntu 3.8.0-33-generic #48~precise1-Ubuntu SMP Thu Oct 24 16:28:06 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

Location of header file, searching via 'locate':

$ locate slab.h
/usr/src/linux-headers-3.8.0-29/include/linux/slab.h
/usr/src/linux-headers-3.8.0-29-generic/include/linux/slab.h
/usr/src/linux-headers-3.8.0-31/include/linux/slab.h
/usr/src/linux-headers-3.8.0-31-generic/include/linux/slab.h
/usr/src/linux-headers-3.8.0-32/include/linux/slab.h
/usr/src/linux-headers-3.8.0-32-generic/include/linux/slab.h
/usr/src/linux-headers-3.8.0-33/include/linux/slab.h
/usr/src/linux-headers-3.8.0-33-generic/include/linux/slab.h
share|improve this question
    
You need to pass the -I/usr/src/linux-headers-3.8.0-33/include/ option to GCC. You may want to learn about Autotools or CMake, that will do the work for you. –  Andrea Corbellini Dec 1 '13 at 19:17
    
Thanks Andrea. I will give it a try and update here. –  smaven Dec 3 '13 at 0:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.