1

For example:

QT used to offer an offline installer for their framework https://www.qt.io/offline-installers

I assume that the installer is coping pre-built runtime libs to the Linux machine. (among other things) but the only thing that they "know" is that it is X64 machine.

If the QT libs are pre-compiled on Linux "X" distro with gcc X_Y_Z how they can be sure they will work on any other distro with different gcc version?

The question is not about QT, it is only as an example to understand how can such installer work.

edit Found this in the qt site , they do require few operating system and compiler versions in order the offline installer will work

So maybe the installer has few built in packages Combination of distro and g++ version and it choose which to install at runtime?

https://doc.qt.io/qt-5/linux.html

1 Answers1

1

If you check the lib directories you will see that there are multiple symlinks.

So for a certain library it could look like this:

libname.so     -> libname.so.1
libname.so.1   -> libname.so.1.8
libname.so.1.8 -> libname.so.1.8.4
libname.so.1.8.4

Library vendors normally give certain API compatibility for their version jumps. So as a developer you could link e.g. against libname.so.1 is you know that the library vendor would only add features and do bugfixes within 1.x.y.

Or you could link against libname.so.1.8 if you want to be more specific about the installed version.

The package provided by the distro (or the vendor) normally provide those version for which breaking changes in the API exists.

So as a library/application developer, you will check the version scheme your dependencies use, and you will link in the least restrictive way that will guarantee you stability and compatibility.

The same will be true for the c++ runtime library:

libstdc++.so        -> libstdc++.so.6.0.28
libstdc++.so.6      -> libstdc++.so.6.0.28
libstdc++.so.6.0.28

The compiler version is not really relevant, relevant is the runtime library, that one needs to be ABI compatible with the binary that is installed.

GCC: ABI Policy and Guidelines

“ library API + compiler ABI = library ABI ”
The library ABI is mostly of interest for end-users who have unresolved symbols and are linking dynamically to the C++ Standard library, and who thus must be careful to compile their application with a compiler that is compatible with the available C++ Standard library binary. In this case, compatible is defined with the equation above: given an application compiled with a given compiler ABI and library API, it will work correctly with a Standard C++ Library created with the same constraints.
[…]
Binaries with equivalent DT_SONAMEs are forward-compatibile: in the table below, releases incompatible with the previous one are explicitly noted. If a particular release is not listed, its libstdc++.so binary has the same filename and DT_SONAME as the preceding release.

So all libstdc++.so.x version are forward compatibility if not mentioned otherwise. So if you build you application against libstdc++.so.6.0.1, it would be compatible with libstdc++.so.6.0.28, so you could link against libstdc++.so.6.

t.niese
  • 39,256
  • 9
  • 74
  • 101
  • I think the OP is not asking about different versions of the downloaded binary, but about different compiler versions. – m7913d Aug 10 '20 at 16:23
  • 1
    @m7913d it was not about the different versions to download, but the different versions of libraries to link against in general, because the problem is not just about the stdlibc++, QT for example links also again a bunch of other shared libraries like libxml. But I added specific information about the `stdlibc++` to clarify this. – t.niese Aug 10 '20 at 16:49
  • my question is not about different versions of library on same arch . it is how library provider can provide SAME library and it is working on all linux platforms and compilers – cant_understand_this Aug 10 '20 at 17:55
  • @user3717741 - simple answer, then. You can't. Btw, that added info just then doesn't match your initial statement. You specified x64 above. – tink Aug 10 '20 at 18:03
  • @t.neise If you follow the qt link you will see single download .run file for linux64 , how does it work? – cant_understand_this Aug 10 '20 at 18:06
  • @tink X64 can be compiled with different compilers versions on different linux distro – cant_understand_this Aug 10 '20 at 18:07
  • Well, yes, but x64 != "all linux platforms" – tink Aug 10 '20 at 18:26
  • @tink you are right , i meant all the 64bit linux distros . – cant_understand_this Aug 10 '20 at 18:34
  • @user3717741 As I said the vendors of the library specify which version of the library (including the stdlibc++) their library uses/requires (e.g. in the deb file). And those are either already installed (like the most common ones) or will be installed with the package manager of the linux distro when the library is installed. If the ABI of the compiled binary matches, then it does not matter which linux distribution it is. All of them us the same binary format for the libraries. – t.niese Aug 10 '20 at 18:41
  • @user3717741 The different Linux distributions still have the same Linux kernel, they just come with a different set of preinstalled libraries and applications. Those are not different OS just different distributions. – t.niese Aug 10 '20 at 18:45
  • " If the ABI of the compiled binary matches, then it does not matter which linux distribution it is. All of them us the same binary format for the libraries" so i can compile g++ XYZ version on centos and if it have runtime lib on ubuntu it will work? if so why the different packages for different distros? – cant_understand_this Aug 10 '20 at 20:11