Linux 预测 2.6.16 和 2.6.26 内核版本之间的“内核太旧”错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6941332/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Anticipate "kernel too old" errors between 2.6.16 and 2.6.26 kernel versions
提问by Aabaz
I build an application on a machine running Linux (Debian) with kernel 2.6.26-2-amd64 and I want to run this application on another machine running Linux (Suse) with kernel 2.6.16.60-0.21-smp but I get the error "FATAL: kernel too old".
我在运行 Linux (Debian) 内核为 2.6.26-2-amd64 的机器上构建了一个应用程序,我想在另一台运行 Linux (Suse) 内核为 2.6.16.60-0.21-smp 的机器上运行这个应用程序,但我收到错误“致命:内核太旧”。
I know from research on the internet that this can happen when building against a glibc library that was not compiled to support older kernel versions, but it usually concerns version 2.4. Is it possible to get such errors for kernel of the same series (2.6) or can this be from something else ?
我从互联网上的研究中了解到,在针对未编译为支持旧内核版本的 glibc 库进行构建时可能会发生这种情况,但通常涉及 2.4 版。对于同一系列(2.6)的内核是否有可能出现此类错误,或者这可能来自其他方面?
Additionally I read that the solution to this problem is to rebuild the application against another version of glibc compiled with appropriate --enable-kernel=VERSION option. As an alternative can you just dynamically link your application with glibc to solve the problem ?
另外我读到这个问题的解决方案是针对使用适当的 --enable-kernel=VERSION 选项编译的另一个版本的 glibc 重建应用程序。作为替代方案,您可以将您的应用程序与 glibc 动态链接来解决问题吗?
Thank you for your help.
感谢您的帮助。
UPDATE: I understand my question may seem vague or solved by one of the solutions already mentionned (dynamically linking, building on another [virtual] system, rebuilding glibc [which seems quite tricky considering the comments I read about it]) but what I am ultimately looking for are ways to prevent such problems.
更新:我知道我的问题可能看起来很模糊,或者已经被提到的解决方案之一解决了(动态链接,在另一个 [虚拟] 系统上构建,重建 glibc [考虑到我读到的评论,这似乎很棘手])但我是什么最终寻找的是防止此类问题的方法。
For instance, is it possible to find which versions of the Linux kernel are compatible with a particular build of glibc ?
例如,是否可以找到哪些版本的 Linux 内核与特定的 glibc 版本兼容?
UPDATE 2: I eventually found a source patch for glibc (for Debian but I guess there are similar docs online for other distros) that (I guess) contains the information I was looking for.
更新 2:我最终找到了 glibc 的源补丁(适用于 Debian,但我想其他发行版的在线文档也有类似的文档),其中(我猜)包含我正在寻找的信息。
--- eglibc-2.11.2.orig/debian/sysdeps/linux.mk
+++ eglibc-2.11.2/debian/sysdeps/linux.mk
@@ -0,0 +1,51 @@
[...]
+MIN_KERNEL_SUPPORTED := 2.6.18
[...]
+# Minimum Kernel supported
+with_headers = --with-headers=$(shell pwd)/debian/include
--enable-kernel=$(call xx,MIN_KERNEL_SUPPORTED)
[...]
Which explains the "kernel too old" error. Hope it helps other people.
这解释了“内核太旧”错误。希望它可以帮助其他人。
采纳答案by Jonathan Callen
One way you can determine the minimum kernel version for a given ELF file is to run file
on it, like so:
确定给定 ELF 文件的最低内核版本的一种方法是file
在其上运行,如下所示:
$ echo 'int main(){}' > test.c
$ gcc -o test test.c
$ file test
test: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.38, not stripped
The important part here is the "for GNU/Linux 2.6.38
", which indicates the minimum kernel version.
这里重要的部分是“ for GNU/Linux 2.6.38
”,它表示最低内核版本。