I build the simplest program on current newest Fedora distribution (35):
$ cat test.c
int main(int argc, char **argv)
{
}
$ cc test.c
The resulting a.out can't be run on an older system, because the glibc on fedora 35 is 2.34:
$ readelf --dyn-sym a.out
Symbol table '.dynsym' contains 3 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __libc_start_main@GLIBC_2.34 (2)
2: 0000000000000000 0 NOTYPE WEAK DEFAULT UND __gmon_start__
For example, on Ubuntu 20 I get this error:
$ ./a.out
./a.out: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by ./a.out)
How can I build an program on newer Linux that can run on older Linux?
I couldn't find any simple solution. There's a complicated one but nothing simple.