简体   繁体   English

编译旧内核的程序

[英]Compiling program for old kernel

I statically compiled and linked a program in an up-to-date Linux machine, and ran it in another Linux which is 9 years old. 我在最新的Linux机器上静态编译和链接程序,并在另一个9岁的Linux中运行它。 It gave me an error "FATAL: kernel too old" and quit. 它给了我一个错误“致命:内核太旧”并退出。 Specifically, the new one is Fedora 18 (gcc 4.7.2, glibc 2.16, kernel 3.7.2) and the old one is RHEL4.8 (glibc 2.3.4, kernel 2.6.9). 具体来说,新的是Fedora 18(gcc 4.7.2,glibc 2.16,内核3.7.2),旧的是RHEL4.8(glibc 2.3.4,内核2.6.9)。 Since it's static linking, glibc version shouldn't matter. 由于它是静态链接,因此glibc版本无关紧要。 I guess the problem here is that the program calls system calls that's not in the old kernel. 我想这里的问题是该程序调用的系统调用不在旧内核中。

If development on the old system is not an option, how can I build the program in the new system and run in the older (or even better, both)? 如果旧系统上的开发不是一个选项,我如何在新系统中构建程序并在较旧的系统中运行(或者甚至更好)? I was looking for a way to run gcc in a compatible mode, which only calls old system calls. 我一直在寻找一种在兼容模式下运行gcc的方法,它只调用旧的系统调用。 No luck yet. 没有运气了。

The easiest option is to always build on the older system. 最简单的选择是始终在旧系统上构建。

Alternatively, copy the glibc headers and static libraries from the old system to the new and link against those. 或者,将glibc头文件和静态库从旧系统复制到新系统并链接到那些。

If that doesn't work, you'll have to rebuild glibc with --enable-kernel=2.6.9 or something like that. 如果这不起作用,你将不得不用--enable-kernel=2.6.9或类似的东西来重建glibc。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM