Empty kernel directory but kernel-headers are installed
I had same problem. After much googling, this solution worked for me. It first determines the installed kernel version and then uses that exact version to install the kernel header package.
sudo yum install "kernel-devel-uname-r == $(uname -r)"
The correct package to install all of the required dependencies for building kernel modules is kernel-devel
(see the CentOS documentation for more information).
The headers are not installed in /usr/src/kernels
, rather they're installed in a number of directories below /usr/include
(the default location for C header files). You can list the contents of the kernel-headers
package you installed using:
rpm -ql kernel-headers
On CentOS version 7 given below is the path for kernel-headers.
/lib/modules/3.10.0-327.36.2.el7.x86_64/build/include
After running yum install kernel-headers
twice (updated to the latest), the problem got fixed. Make sure the running kernel version and the kernel headers version are same. My kernel version is 3.10.0-327.36.2.el7.x86_64