Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. 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). Since it's static linking, glibc version shouldn't matter. 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. No luck yet.

like image 935
Wu Yongzheng Avatar asked Jan 16 '13 16:01

Wu Yongzheng


People also ask

Should you compile your own kernel?

The advantages of compiling your own kernel include being able to tune the kernel to your specific hardware, and ending up with a smaller kernel. You may also need to compile your own kernel if the default kernel does not support some specific hardware you have.

Why do we need to compile kernel?

The main purpose of kernel compilation is to provide hardware support and software support that you do not need, or to add the software and hardware tools you need.

What does compiling a kernel mean?

Yes, compiling a kernel usually means: Downloading the source code. Possibly modifying the source code (most non-programmers don't usually do this). Configuring the kernel (what features/modules/drivers to include, etc.) Compiling it.


1 Answers

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.

If that doesn't work, you'll have to rebuild glibc with --enable-kernel=2.6.9 or something like that.

like image 74
ams Avatar answered Sep 18 '22 12:09

ams