GLIB : ERROR /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found

Hi,

I’m working on GTK3 desktop application in cpp. I built my application on an ubuntu machine with

(Ubuntu GLIBC 2.35-0ubuntu3.5) 2.35

and i was able to run this application on that machine. But when i tried to run the application in different ubuntu machine with

(Ubuntu GLIBC 2.31-0ubuntu9.14) 2.31

I got the error saying

./source: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34’ not found (required by ./source)

Does this mean, GLIB is not backward compatible?

I thought of statically linking the GLIB lib until i read that it is not recommended.

How to fix this issue? i want to build an app which is backward compatible till Ubuntu 18.04 LTS.

Thank you

I think you got backward backwards. Stuff compiled against glibc 2.31 can run perfectly fine on glibc 2.35, but not the other way round.

Also glibc here is libc, not glib.

1 Like

Note: Ubuntu 18.04 has reached EOL status in April 2023. People still using it are either paying Canonical for Pro support, or they are exposing themselves to plausible security issues.

If you want to support this kind of old platforms, the recommendation is to use sandboxing technologies, like Flatpak or Snap.

Glibc (GNU C library) is not GLib; and this is not what backward compatibility is, either: there’s no guarantee that a binary compiled against a newer version of a library can be then run against an older version of the same library.

1 Like

thank you for the response @ebassi , If we manage to link the libc library statically can this help us solve the issue?

No, compiling against a static GNU libc won’t do you any good. The answer on StackOverflow you linked explains why.

1 Like

Recommendations:

  • Build on the oldest system that you support. glibc and GLib are both backwards compatible. Neither is forwards compatible. Expecting software built on the newer system to work on the older system would require forwards compatibility, i.e. it would require that nothing new is ever added.
  • Do a quick check to learn the difference between glibc vs. GLib. They are entirely unrelated. Perhaps the names are confusingly-similar, but it’s too late to avoid that.
  • As Emmanuele suggested, strongly consider using Flatpak or Snap instead.
2 Likes

Thank you. This was helpful

@ebassi , I’m trying to understand the problem a bit better. I tried to build an executable to print “Hello World!” to the console with the command

g++ -o source source.cpp

. But even that minimal program is causing the GLIBC version compatibility error.

I understand GLIBC is a collection of C library functions that provide low-level functionality to the operating system. But why is this minimal program causing the version compatibility issue?

As GLIBC is a wrapper on the Linux kernel for system calls, and I read “glibc does not “implement” system calls, kernel does it. But glibc provides the user land interface to the services provided by kernel so that user application can use a system call just like a ordinary function” does this mean even a very minimal c/c++ program will link with GLIBC? Even the one which will just return 0?

Please correct me if I misunderstood anything.

Thank You

You can compile code with gcc -nostdlibc -nolibc (-nostdlib++ for g++) if you do not wan’t to link against glibc.

Keep in mind that glibc initializes the runtime for you and when building without it, main() won’t get called. Instead you have to provide a void _start(long* init) symbol that may not return (if it were to return it’ll segfault), and you’ll need to call syscalls youself like so:

void _start(void) {
        __asm__(\
                "mov $60,%rax\n\t" \
                "mov $42,%rdi\n\t" \
                "syscall\n\t"
        );
}

Also note that glibc is not part of the GNOME project (glib is). So ideally you’d ask on the libc-help list (or stackoverflow)

1 Like

I literally have no idea what you want to achieve, but I also know that this is not the forum to ask about GNU libc issues.

Yes, you won’t be able to work around that; anything that uses any libc call—which means everything that isn’t a Go program—will need to link against the libc, and you won’t be able to use something built against a newer version of libc against an older version, because nothing works that way.

That’s just one of the things the standard C library does.

The recommendation is:

  • do not support versions of Ubuntu that are EOL
  • do not build your application on a newer version of the OS and then run it on an older one

If you want to support Ubuntu 18.04, for some weird reason, you will need to build your code on Ubuntu 18.04.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.