0

I have two machines,

  1. RHEL 4 machine
  2. RHEL 6 machine

Now I have a code that I can compile on RHEL4 machine and then run the executable on both machines. But if I compile the same code on RHEL6 machine, I cannot run the executable on RHEL4 machine. It throws an error "GLIBC 2.7 version required".

Now my quesiton is, GLIBC 2.7 on RHEL6 machine already supports earlier versions and has headers related to earlier versions. So can I somehow tell my gcc compiler to use a particular earlier version of gcc to compile the code. (Since it can be compiled on earlier versions...)

More Info:

$readelf -a glibc

on RHEL4 machine shows,

  Addr: 0x0000000000014428  Offset: 0x014428  Link: 4 (.dynstr)
  000000: Rev: 1  Flags: BASE   Index: 1  Cnt: 1  Name: libc.so.6
  0x001c: Rev: 1  Flags: none  Index: 2  Cnt: 1  Name: GLIBC_2.2.5
  0x0038: Rev: 1  Flags: none  Index: 3  Cnt: 2  Name: GLIBC_2.2.6
  0x0054: Parent 1: GLIBC_2.2.5
  0x005c: Rev: 1  Flags: none  Index: 4  Cnt: 2  Name: GLIBC_2.3
  0x0078: Parent 1: GLIBC_2.2.6
  0x0080: Rev: 1  Flags: none  Index: 5  Cnt: 2  Name: GLIBC_2.3.2
  0x009c: Parent 1: GLIBC_2.3
  0x00a4: Rev: 1  Flags: none  Index: 6  Cnt: 2  Name: GLIBC_2.3.3
  0x00c0: Parent 1: GLIBC_2.3.2
  0x00c8: Rev: 1  Flags: none  Index: 7  Cnt: 2  Name: GLIBC_2.3.4
  0x00e4: Parent 1: GLIBC_2.3.3
  0x00ec: Rev: 1  Flags: none  Index: 8  Cnt: 2  Name: GLIBC_PRIVATE
  0x0108: Parent 1: GLIBC_2.3.4

$readelf -a glibc on RHEL6 machine shows,

Version definition section '.gnu.version_d' contains 17 entries:

  Addr: 0x00000031b2a16eb8  Offset: 0x016eb8  Link: 5 (.dynstr)
  000000: Rev: 1  Flags: BASE   Index: 1  Cnt: 1  Name: libc.so.6
  0x001c: Rev: 1  Flags: none  Index: 2  Cnt: 1  Name: GLIBC_2.2.5
  0x0038: Rev: 1  Flags: none  Index: 3  Cnt: 2  Name: GLIBC_2.2.6
  0x0054: Parent 1: GLIBC_2.2.5
  0x005c: Rev: 1  Flags: none  Index: 4  Cnt: 2  Name: GLIBC_2.3
  0x0078: Parent 1: GLIBC_2.2.6
  0x0080: Rev: 1  Flags: none  Index: 5  Cnt: 2  Name: GLIBC_2.3.2
  0x009c: Parent 1: GLIBC_2.3
  0x00a4: Rev: 1  Flags: none  Index: 6  Cnt: 2  Name: GLIBC_2.3.3
  0x00c0: Parent 1: GLIBC_2.3.2
  0x00c8: Rev: 1  Flags: none  Index: 7  Cnt: 2  Name: GLIBC_2.3.4
  0x00e4: Parent 1: GLIBC_2.3.3
  0x00ec: Rev: 1  Flags: none  Index: 8  Cnt: 2  Name: GLIBC_2.4
  0x0108: Parent 1: GLIBC_2.3.4
  0x0110: Rev: 1  Flags: none  Index: 9  Cnt: 2  Name: GLIBC_2.5
  0x012c: Parent 1: GLIBC_2.4
  0x0134: Rev: 1  Flags: none  Index: 10  Cnt: 2  Name: GLIBC_2.6
  0x0150: Parent 1: GLIBC_2.5
  0x0158: Rev: 1  Flags: none  Index: 11  Cnt: 2  Name: GLIBC_2.7
  0x0174: Parent 1: GLIBC_2.6
  0x017c: Rev: 1  Flags: none  Index: 12  Cnt: 2  Name: GLIBC_2.8
  0x0198: Parent 1: GLIBC_2.7
  0x01a0: Rev: 1  Flags: none  Index: 13  Cnt: 2  Name: GLIBC_2.9
  0x01bc: Parent 1: GLIBC_2.8
  0x01c4: Rev: 1  Flags: none  Index: 14  Cnt: 2  Name: GLIBC_2.10
  0x01e0: Parent 1: GLIBC_2.9
  0x01e8: Rev: 1  Flags: none  Index: 15  Cnt: 2  Name: GLIBC_2.11
  0x0204: Parent 1: GLIBC_2.10
  0x020c: Rev: 1  Flags: none  Index: 16  Cnt: 2  Name: GLIBC_2.12
  0x0228: Parent 1: GLIBC_2.11
  0x0230: Rev: 1  Flags: none  Index: 17  Cnt: 2  Name: GLIBC_PRIVATE
  0x024c: Parent 1: GLIBC_2.12

So is there not a way I can compile code on RHEL6 using GLIBC 2.3.4 headers. Since I am not using anything new which was not in GLIBC 2.3.4

Shray
  • 181
  • 1
  • 9
  • 1
    Does this answer your question? [How can I link to a specific glibc version?](https://stackoverflow.com/questions/2856438/how-can-i-link-to-a-specific-glibc-version) – Łukasz Ślusarczyk Aug 18 '20 at 18:41
  • @ŁukaszŚlusarczyk I doubt that's useful here. Unless one can keep track of all possible symbols that might get used from newer glibc and the respective older symbols versions are used instead (which is impractical when you *just compile*), it's not going to work. In that case, why not just compile on the older systems? – P.P Aug 18 '20 at 19:02

1 Answers1

1

Let's confirm the default glibc versions on RHEL. From distrowatch for RHEL:

  • RHEL 4 has glibc 2.3.4
  • RHEL 6 has glibc 2.12

I cannot run the executable on RHEL4 machine. It throws an error "GLIBC 2.7 version required".

There are newer symbol versions in glibc since 2.3.4 that are in 2.12 but not in 2.3.4. So this is expected and won't work.

Now my quesiton is, GLIBC 2.7 on RHEL6 machine already supports earlier versions and has headers related to earlier versions.

Yes. But when you compile with glibc 2.12, it may use symbols that are not in older glibc versions.

So can I somehow tell my gcc compiler to use a particular earlier version of gcc to compile the code.

It's the compiler - gcc - that's the problem here. It's glibc library. Even if you install an older gcc on a system with glibc 2.12, you'll still have the same problem.

So is there not a way I can compile code on RHEL6 using GLIBC 2.3.4 headers. Since I am not using anything new which was not in GLIBC 2.3.4

Again, you're mixing up lots of things - headers are not the issue. It's glibc library and specifically the newer symbols it uses. "You" may not be using anything specific to glibc 2.12 but newer symbols may be pulled in automatically. And evidently that's what happens in your case.

I am not sure why you want to do this. If you're happy with RHEL 4 (glibc 2.3.4), then why compile on it and use it on RHEL 6 - since newer glibc are going to have older symbols.

P.P
  • 117,907
  • 20
  • 175
  • 238