Reputation: 639
I'm trying to compile a program with this gcc command:
gcc -c -fomit-frame-pointer -O2 sth.c
These header files are included:
#include <linux/kernel.h> //line 1
#include <linux/module.h> //line 2
#include <sys/syscall.h> //line 3
#include <linux/proc_fs.h> //line 4
#include <linux/types.h> //line 5
#include <linux/dirent.h> //line 6
#include <asm/unistd.h> //line 7
I get "no such file or directory"
error for line 2,4 and 6 though they are located in /usr/src/kernels/3.10.14-100.fc18.x86_64/include/linux/
just as the other 4.
I've compiled some other programs whitch include kernel header files on this system before (using Makefiles) (fedora 18) before and I'm sure for example it didn't get such error for dirent.h
or proc_fs.h
.
I think maybe I should use some other options with gcc that maybe was considered in those Makefiles!
kernel-headerfiles
and kernel-devel
package of the same version of my running kernel is installed.
Upvotes: 0
Views: 3186
Reputation: 51832
The userspace kernel headers are located in /usr/include/linux
, not in /usr/src/...
. The latter path contains headers intended for kernel modules, not userspace programs.
If the program is question is actually a kernel module, then you need to use KBuild in order to compile it, since kernel modules need a special build environment. See: Understand what is KBuild
Also take a look at:
/usr/src/linux/Documentation/kbuild/modules.txt
Upvotes: 1