1. 程式人生 > 實用技巧 >Linux Make 報錯:make: *** /lib/modules/3.10.0-1127.el7.x86_64/build: no such file or directory. stop.

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你自己的程式碼。