0

Arch Linux is on GLIBC version 2.33 : https://archlinux.org/packages/core/x86_64/glibc/

but Ubuntu 20.04 is on GLIBC 2.31:

$/lib/x86_64-linux-gnu/libc.so.6 --version
GNU C Library (Ubuntu GLIBC 2.31-0ubuntu9.2) stable release version 2.31.

So, when I try to run on Ubuntu 20.04 the executable produced by CX_Freeze on my Arch Linux system, I get:

./Documents/exe.linux-x86_64-3.8/myapp: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by ./Documents/exe.linux-x86_64-3.8/myappp
./Documents/exe.linux-x86_64-3.8/myapp: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by ./Documents/exe.linux-x86_64-3.8/myapp)

How to make an executable from Arch linux which works on older Linux system like Ubuntu 20.04 (in term of GLIBC)?

ThePhi
  • 2,373
  • 3
  • 28
  • 38
  • What's the question? I see a statement of fact.. – tehhowch Jun 04 '21 at 13:12
  • @tehhowch sorry, I've edited – ThePhi Jun 04 '21 at 13:14
  • what research did you do? ex. https://stackoverflow.com/questions/2856438/how-can-i-link-to-a-specific-glibc-version https://stackoverflow.com/questions/49302522/build-for-older-glibc https://stackoverflow.com/questions/4032373/linking-against-an-old-version-of-libc-to-provide-greater-application-coverage https://unix.stackexchange.com/questions/420513/will-a-linux-executable-compiled-on-one-flavor-of-linux-run-on-a-different-one – KamilCuk Jun 04 '21 at 13:24
  • @KamilCuk It's interesting (I didn't use the term `linker` in my search but only `cx-freeze` and `glibc` which gets nothing). But it doesn't explain how to do it with CX_Freeze. – ThePhi Jun 04 '21 at 13:27

2 Answers2

0

How to make an executable from Arch linux which works on older Linux system like Ubuntu 20.04 (in term of GLIBC)?

Options:

  • run Ubuntu 20.04 in a virtualized environment and compile it there (ie. docker), or
  • compile glibc 2.31 from sources and install on archlinux and link your application with it, or
  • downgrade archlinux to the version with glibc 2.31, or
  • link statically with glibc or with other C standard library, or
  • copy compiled glibc libraries and distribute it with your application with a custom configuration and some startup script, or
  • distribute the whole chroot with archlinux with your application installed (you could use systemd-machine or publish docker image or similar).

TBH just run ubuntu:20.04 in a docker and build your application there. Typically applications are built for each distribution separately anyway.

KamilCuk
  • 120,984
  • 8
  • 59
  • 111
  • `link your application with it` Can you describe how to do it with CX_Freeze? – ThePhi Jun 04 '21 at 13:24
  • No, I cannot. I do not have experience with it. – KamilCuk Jun 04 '21 at 13:26
  • cx-freeze-6.6 is in PyPi, can be installed with pip3 : `pip3 install cx-freeze` – Knud Larsen Jun 04 '21 at 15:59
  • Even more briefly, just do what you already did, but inside an Ubuntu 20.04 container or in another suitably compatible environment. Generally speaking, stuff made on an older system will run fine on a slightly newer system, whereas the opposite cannot be expected. – tripleee Jun 05 '21 at 07:30
  • 1
    `LD_PRELOAD` of newer GLIBC will not work: https://stackoverflow.com/a/851229/50617 – Employed Russian Jun 06 '21 at 15:51
  • Right - but, you can do `/path/to/your/ld-linux.so.2 executable` to handle interpreter. – KamilCuk Jun 06 '21 at 16:08
-1

You need to build a glibc from source and put all the libraries in a folder.

For example, for a Ubuntu 20.04 targeted system (which understands only executables compiled with GLIBC_2.31), put in a GLIBC_LIB folder the 5 produced so files:

  • ld-2.31.so
  • ld-linux-x86-64.so.2
  • libc.so.6
  • libm.so.6
  • libpthread.so.0

Then, run CX_Freeze with this:

LD_LIBRARY_PATH=/path/to/GLIBC_LIB python setup.py build

Note: you can't link a specific library file, you need to link a folder where the library is.

ThePhi
  • 2,373
  • 3
  • 28
  • 38