Linux Make 报错:make: *** /lib/modules/3.10.0-1127.el7.x86_64/build: no such file or directory. stop.

测试环境:Centos 7

原因:/lib/modules/3.10.0-1127.el7.x86_64/build没有指向正确的kernel source

查看:

[root@localhost 3.10.0-1127.el7.x86_64]# ll
total 3296
lrwxrwxrwx.  1 root root     39 May 22  2019 build -> /usr/src/kernels/3.10.0-1127.el7.x86_64
drwxr-xr-x.  2 root root      6 Mar 31 19:40 extra
drwxr-xr-x. 12 root root    128 May 22  2019 kernel
-rw-r--r--.  1 root root 860010 May 22  2019 modules.alias
-rw-r--r--.  1 root root 819598 May 22  2019 modules.alias.bin
-rw-r--r--.  1 root root   1333 Mar 31 19:40 modules.block
-rw-r--r--.  1 root root   7391 Mar 31 19:40 modules.builtin
-rw-r--r--.  1 root root   9440 May 22  2019 modules.builtin.bin
-rw-r--r--.  1 root root 273097 May 22  2019 modules.dep
-rw-r--r--.  1 root root 381959 May 22  2019 modules.dep.bin
-rw-r--r--.  1 root root    361 May 22  2019 modules.devname
-rw-r--r--.  1 root root    140 Mar 31 19:40 modules.drm
-rw-r--r--.  1 root root     69 Mar 31 19:40 modules.modesetting
-rw-r--r--.  1 root root   1810 Mar 31 19:40 modules.networking
-rw-r--r--.  1 root root  97901 Mar 31 19:40 modules.order
-rw-r--r--.  1 root root    569 May 22  2019 modules.softdep
-rw-r--r--.  1 root root 397440 May 22  2019 modules.symbols
-rw-r--r--.  1 root root 486116 May 22  2019 modules.symbols.bin
lrwxrwxrwx.  1 root root      5 May 22  2019 source -> build
drwxr-xr-x.  2 root root      6 Mar 31 19:40 updates
drwxr-xr-x.  2 root root     95 May 22  2019 vdso
drwxr-xr-x.  2 root root      6 Mar 31 19:40 weak-updates

我的终端上,标注的那两行会一闪一闪的,提示我链接有问题。

原因是没有内核开发包,下载安装即可:

yum install kernel-devel-$(uname -r)

安装完再去make你自己的代码。

原文地址:https://www.cnblogs.com/zoneofmine/p/13552532.html