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.
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.
@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?
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:
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.