出現的問題:
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'