GCC libc.so.6 Version GLIBC_X.XX Not Found

(Reproduce & Troubleshoot Series)

1 Overview

2 Reproduce

Find gcc and fedora version mapping at koji.fedoraproject.org:

Through the RPM names, we have the below mapping:

Step 1: Create docker container of fedora 33.

host$ cat Dockerfile.f33
FROM fedora:33
RUN dnf group install -y c-development
CMD ["tail", "-f", "/dev/null"]
host$ docker build --tag fedora33 --file Dockerfile.f33 .
host$ docker create --name f33 --hostname f33 fedora33
host$ docker start f33

Step 2: Create docker container of fedora 44.

host$ cat Dockerfile.f44
FROM fedora:33
RUN dnf group install -y c-development
CMD ["tail", "-f", "/dev/null"]
host$ docker build --tag fedora44 --file Dockerfile.f44 .
host$ docker create --name f44 --hostname f44 fedora44
host$ docker start f44

Step 3: Check gcc and libc version on the containers.

f33$ g++ --version
g++ (GCC) 10.3.1 20210422 (Red Hat 10.3.1-1)

f33$ ldd --version
ldd (GNU libc) 2.32
f44$ g++ --version
g++ (GCC) 16.2.1 20260819 (Red Hat 16.2.1-2)

f44$ ldd --version
ldd (GNU libc) 2.43

Step 4: On fedora 44, build a binary.

f44$ cat main.cpp
#include <iostream>

int main()
{
    std::cout << "hello" << std::endl;
    return 0;
}
f44$ g++ main.cpp -o main

f44$ ./main
hello

Step 5: On fedora 33, run the binary which is built from fedora 44.

host$ docker cp f44:/root/main .
host$ docker cp main f33:/root
f33$ ./main
./main: /lib64/libc.so.6: version `GLIBC_2.34' not found (required by ./main)
./main: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.32' not found (required by ./main)

3 Root Cause Analysis

f33$ ldd main
./main: /lib64/libc.so.6: version `GLIBC_2.34' not found (required by ./main)
./main: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.32' not found (required by ./main)
    linux-vdso.so.1 (0x0000ffff8467c000)
    libstdc++.so.6 => /lib64/libstdc++.so.6 (0x0000ffff8442a000)
    libm.so.6 => /lib64/libm.so.6 (0x0000ffff84379000)
    libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x0000ffff84348000)
    libc.so.6 => /lib64/libc.so.6 (0x0000ffff841c2000)
    /lib/ld-linux-aarch64.so.1 (0x0000ffff84630000)
f44$ strings main | grep GLIBC
GLIBC_2.17
GLIBC_2.34
GLIBCXX_3.4.32
GLIBCXX_3.4
__libc_start_main@GLIBC_2.34
_ZSt4cout@GLIBCXX_3.4
_ZSt21ios_base_library_initv@GLIBCXX_3.4.32
abort@GLIBC_2.17
...
f33$ strings /lib64/libc.so.6 | grep GLIBC
GLIBC_2.17
GLIBC_2.18
...
GLIBC_2.30
GLIBC_2.32
f33$ strings /lib64/libstdc++.so.6 | grep GLIBCXX
GLIBCXX_3.4
GLIBCXX_3.4.1
...
GLIBCXX_3.4.27
GLIBCXX_3.4.28

Root Cause