出现的问题:
make -C /lib/modules/`uname -r`/build M=`pwd` modules
make: *** /lib/modules/2.6.32-573.el6.x86_64/build: No such file or directory. Stop.
解决方法:
[shaocongshuai@localhost ~]$ ls /usr/src/kernels/
如果该目录为空,则删掉这个build的空链接
[shaocongshuai@localhost ~]$ cd /lib/modules/2.6.32-573.el6.x86_64/
[shaocongshuai@localhost 2.6.32-573.el6.x86_64]$ rm -f build
再安装更新包
[shaocongshuai@localhost ~]$ sudo yum install kernel-devel
然后重新建立链接
[shaocongshuai@localhost ~]$ sudo ln -s ../../../usr/src/kernels/2.6.32-573.12.1.el6.x86_64/ build
再编译就OK了,
[shaocongshuai@localhost ~]$ make
make -C /lib/modules/`uname -r`/build M=`pwd` modules
make[1]: Entering directory `/usr/src/kernels/2.6.32-573.12.1.el6.x86_64'
CC [M] /home/shaocongshuai/hello.o
Building modules, stage 2.
MODPOST 1 modules
CC /home/shaocongshuai/hello.mod.o
LD [M] /home/shaocongshuai/hello.ko.unsigned
NO SIGN [M] /home/shaocongshuai/hello.ko
make[1]: Leaving directory `/usr/src/kernels/2.6.32-573.12.1.el6.x86_64'