我已经在centos上安装了kernel-devel,仍然找不到内核头文件

时间:2017-03-21 08:04:32

标签: c linux file header

我已经在centos上安装了kernel-devel,仍然找不到内核头文件

# yum install kernel-devel
Loaded plugins: fastestmirror, ovl
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: mirrors....net
 * extras: ...
 * updates: mirrors.....net
Package kernel-devel-2.6.32-642.15.1.el6.x86_64 already installed and latest version

但是gcc找不到头文件:

# cat testkmem.c
#include<sys/types.h>
#include<sys/kmem.h>
int main(){

    return 0;
}

# gcc testkmem.c
testkmem.c:2:21: error: sys/kmem.h: No such file or directory

如何解决这个编译问题,需要任何额外的yum包?

1 个答案:

答案 0 :(得分:1)

你知道locate命令吗?

$ locate kmem.h
/usr/src/kernels/3.10.0-514.10.2.el7.x86_64/include/config/memcg/kmem.h
/usr/src/kernels/3.10.0-514.10.2.el7.x86_64/include/trace/events/kmem.h

:-),我认为你的 PATH 有错误。