-1

I am a newer in linux and using ubuntu(4.4.0-64-generic) in vmware fusion. I am learning how to compile kernel. So, I downloaded the kernel(linux-4.4.52.tar.xz) from the kernel.org. But when I input make menuconfig, there are some errors.

root@ubuntu:/usr/src/linux-4.4.52# make menuconfig

HOSTCC scripts/basic/fixdep
In file included from /usr/include/x86_64-linux-gnu/bits/posix1_lim.h:160:0,
from /usr/include/limits.h:143,
from /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/limits.h:168,
from /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/syslimits.h:7,
from /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/limits.h:34,
from scripts/basic/fixdep.c:114: /usr/include/x86_64-linux-gnu/bits/local_lim.h:38:26: fatal error: linux/limits.h: No such file or directory
compilation terminated.
scripts/Makefile.host:91: recipe for target 'scripts/basic/fixdep' failed
make[1]: * [scripts/basic/fixdep] Error 1
Makefile:444: recipe for target 'scripts_basic' failed
make: *
[scripts_basic] Error 2

I have installed headers files and done everything I can do. Someone can help me solve this problem?

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Jerry
  • 11
  • 1
  • 6
  • Which header files did you install? – CL. Mar 05 '17 at 12:55
  • linux-headers-4.4.0-31, linux-headers-4.4.0-31-generic, linux-headers-4.4.0-62, linux-headers-4.4.0-62-generic, linux-headers-4.4.0-64, linux-headers-4.4.0-64-generic. These are all header documents I find in /usr/src. – Jerry Mar 05 '17 at 14:46
  • But where does `/usr/include/linux` point to? – CL. Mar 05 '17 at 15:20
  • I think it points to 4.4.0-64-generic. Cause I typed rm -rf asm linux scsi, ln -s /usr/src/linux-4.4.0-64-generic/include/asm-generic asm ln -s /usr/src/linux-4.4.0-64-generic/include/linux linux ln -s /usr/src/linux-4.4.0-64-generic/include/scsi scs. The 4.4.0-64-generic is my current kernel version. – Jerry Mar 06 '17 at 02:22
  • So does `/usr/include/linux/limits.h` exist? – CL. Mar 06 '17 at 10:17
  • The limits.h exists in /usr/include/limits.h. I can not go into the /usr/include/linux, that shows "bash: cd: linux: No such file or directory". But the /usr/include/ path has a "linux". – Jerry Mar 06 '17 at 14:05
  • What is the output of `ls -l /usr/include/linux`? – CL. Mar 06 '17 at 15:07
  • Here is the output: lrwxrwxrwx 1 root root 45 Mar 5 21:17 /usr/include/linux -> /usr/src/linux-4.4.0-64-generic/include/linux – Jerry Mar 07 '17 at 02:08
  • Does that directory exist? Does `/usr/src/linux-4.4.0-64-generic/include/uapi/` exist? – CL. Mar 07 '17 at 08:19
  • Yes, it has /usr/src/linux-headers-4.4.0-64/include/uapi – Jerry Mar 07 '17 at 13:38

1 Answers1

0

You symbolic link is wrong; /usr/src/linux-4.4.0-64-generic/include/linux is the wrong directory and must not be linked to /usr/include/linux.

The kernel has two sets of headers: kernel-internal headers, and user API headers. The latter are inside the uapi directory, and they are what user-space program should see.

When you are compiling your own kernel, you can install the user-space headers of that kernel with make headers_install. When you are using your distribution's kernel, you can just (re-)install the appropriate package (in your case, linux-headers-generic), and that will do the right thing as long as you do not muck around with those files afterwards.

CL.
  • 173,858
  • 17
  • 217
  • 259
  • Thank you for your reply. But when I execute the command make heardes_install_all or make headers_install in /usr/src/linux-4.4.52, it still has the error "linux/limits.h: No such file or directory". Am I going in the wrong way? What are the steps to fix this problem? – Jerry Mar 07 '17 at 19:53
  • Don't mix the distribution's packages and your own customizations, unless you know what you're doing. Repair the package by reinstalling it. – CL. Mar 07 '17 at 20:52
  • You mean I should execute "make hearde_install" under /usr/src/linux-headers-4.4.0-64-generic? – Jerry Mar 07 '17 at 21:07
  • You have manually created your own symbolic link `/usr/include/linux`. You have to restore it to the original state somehow. (And `make` runs only from the kernel source, and only after compiling it correctly.) – CL. Mar 08 '17 at 08:19