Skip to content

Instantly share code, notes, and snippets.

@yermulnik
Last active November 12, 2023 21:59
Show Gist options
  • Save yermulnik/5b1d412ca01630af4d06c2c1fadddc53 to your computer and use it in GitHub Desktop.
Save yermulnik/5b1d412ca01630af4d06c2c1fadddc53 to your computer and use it in GitHub Desktop.
Telegram Desktop (messenger) v4.10+ using Glibc 2.29 on Linux Mint 19.3 (Tricia) [Ubuntu 18.04 LTS (Bionic Beaver)]

ℹ️ GH Gist: yermulnik/Telegram.yz.md

👉 Update this gist:

gh gist edit https://gist.github.com/yermulnik/5b1d412ca01630af4d06c2c1fadddc53 -f Telegram.yz.md README.md

Starting with v4.10.0 Telegram has stopped supporting Linux platforms with glibc (GNU C Library) less than 2.29 (2.28?):

> strings Telegram.4.11.3 | fgrep GLIBC_2.2 | tail -1
GLIBC_2.28

Linux Mint 19.3 (Tricia) [Ubuntu 18.04 LTS (Bionic Beaver)] ships with glibc 2.27:

> strings /lib/x86_64-linux-gnu/libc.so.6 | fgrep GLIBC_2.2 | tail -1
GLIBC_2.27

While modern Telegram might be installed and run by means of snap or flatpak, here's the workaround on how to run it on Linux Mint 19.3 (Tricia) [based on Ubuntu 18.04 LTS (Bionic Beaver)] w/o "shims" like snap/flatpak:

  • Caveats:

    • The below example assumes /opt/glibc-2.29 as a destination directory for Glibc and auxiliary libs, and /opt/Telegram.yz as destination for patched Telegram binary. Adjust these paths if you'd like to do the things w/o root permissions (which is a recommended way).
    • Telegram auto-update feature won't be working, meaning you will need to execute Download and patch Telegram binary step each time new version of Telegram is released
    • The Expat (XML parsing C library) installation might be a hassle and is not described in this example as luckily for me it was already installed as a required dependency of something else installed via Homebrew: https://docs.brew.sh/Homebrew-on-Linux
    • Sound doesn't work. Need to figure this out (no ideas and cues yet), though I don't actually listen to audio/video on desktop version.
      • ⚠️ Workarounded this as of now by enabling external video player under experimental settings under advanced settings menu 🤷
        • 😢 This breaks notification sounds ❔ 🤔
  • Download and install Glibc 2.29:

    cd /tmp/
    wget -c https://ftp.gnu.org/gnu/glibc/glibc-2.29.tar.gz
    tar -zxvf glibc-2.29.tar.gz
    mkdir glibc-2.29/build
    cd glibc-2.29/build
    ../configure --prefix=/opt/glibc-2.29
    make 
    make install
    cd ../../ && rm -rf glibc-2.29.tar.gz glibc-2.29/
  • Provide correct Timezone knowledge to this custom installation of Glibc:

    ln -s /etc/localtime /opt/glibc-2.29/etc/
  • Link libs required by Telegram into custom Glibc's libs directory

    • You may need to adjust source locations of some of the libs and/or install missing libs if any
    • libexpat may become a pain as it's only v2.2.5 on this box, while more modern version is required by Telegram, though happily I'm a user of Homebrew on Linux, that has Expat of version 2.5.0)
    ln -s /home/linuxbrew/.linuxbrew/lib/libexpat.so.1 /opt/glibc-2.29/lib/
    
    ln -s /lib/x86_64-linux-gnu/libblkid.so.1 /opt/glibc-2.29/lib/
    ln -s /lib/x86_64-linux-gnu/libbsd.so.0 /opt/glibc-2.29/lib/
    ln -s /lib/x86_64-linux-gnu/libdbus-1.so.3 /opt/glibc-2.29/lib/
    ln -s /lib/x86_64-linux-gnu/libgcrypt.so.20 /opt/glibc-2.29/lib/
    ln -s /lib/x86_64-linux-gnu/libgpg-error.so.0 /opt/glibc-2.29/lib/
    ln -s /lib/x86_64-linux-gnu/liblzma.so.5 /opt/glibc-2.29/lib/
    ln -s /lib/x86_64-linux-gnu/libmount.so.1 /opt/glibc-2.29/lib/
    ln -s /lib/x86_64-linux-gnu/libpcre.so.3 /opt/glibc-2.29/lib/
    ln -s /lib/x86_64-linux-gnu/libselinux.so.1 /opt/glibc-2.29/lib/
    ln -s /lib/x86_64-linux-gnu/libsystemd.so.0 /opt/glibc-2.29/lib/
    ln -s /lib/x86_64-linux-gnu/libuuid.so.1 /opt/glibc-2.29/lib/
    ln -s /lib/x86_64-linux-gnu/libz.so.1 /opt/glibc-2.29/lib/
    
    ln -s /usr/lib/x86_64-linux-gnu/libatk-1.0.so.0 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libatk-bridge-2.0.so.0 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libatspi.so.0 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libcairo-gobject.so.2 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libcairo.so.2 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libdatrie.so.1 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libepoxy.so.0 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libffi.so.6 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libfontconfig.so.1 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libfreetype.so.6 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libgdk-3.so.0 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so.0 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libGL.so.1 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libGLX.so.0 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libgmodule-2.0.so.0 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libgraphite2.so.3 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libgtk-3.so.0 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libharfbuzz.so.0 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/liblz4.so.1 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libpango-1.0.so.0 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libpangocairo-1.0.so.0 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libpixman-1.so.0 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libpng16.so.16 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libthai.so.0 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libwayland-client.so.0 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libwayland-client.so.0.3.0 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libwayland-cursor.so.0 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libwayland-cursor.so.0.0.0 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libwayland-egl.so.1 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libwayland-egl.so.1.0.0 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libwayland-server.so.0 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libwayland-server.so.0.1.0 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libX11.so.6 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libX11-xcb.so.1 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libXau.so.6 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libxcb-render.so.0 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libxcb-shm.so.0 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libxcb.so.1 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libXcomposite.so.1 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libXcursor.so.1 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libXdamage.so.1 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libXext.so.6 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libXfixes.so.3 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libXinerama.so.1 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libXi.so.6 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libxkbcommon.so.0 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libXrandr.so.2 /opt/glibc-2.29/lib/
    ln -s /usr/lib/x86_64-linux-gnu/libXrender.so.1 /opt/glibc-2.29/lib/
  • Download and patch Telegram binary:

    mkdir /opt/Telegram.yz/ && cd /opt/Telegram.yz/
    wget https://telegram.org/dl/desktop/linux -O tsetup.tar.xz
    tar vfx tsetup.tar.xz --strip-components=1
    rm tsetup.tar.xz
    patchelf --set-interpreter /opt/glibc-2.29/lib/ld-linux-x86-64.so.2 --set-rpath /opt/glibc-2.29/ ./Telegram
  • Create (or update your existing Telegram Desktop file) to use correct path:

    > cat ~/.local/share/applications/org.telegram.desktop._0c0ce06c94b8dbcd209b995362e84495.desktop
    [Desktop Entry]
    Name=Telegram Desktop
    Comment=Official desktop version of Telegram messaging app
    TryExec=/opt/Telegram.yz/Telegram
    Exec=/opt/Telegram.yz/Telegram -- %u
    Icon=telegram
    Terminal=false
    StartupWMClass=TelegramDesktop
    Type=Application
    Categories=Chat;Network;InstantMessaging;Qt;
    MimeType=x-scheme-handler/tg;
    Keywords=tg;chat;im;messaging;messenger;sms;tdesktop;
    Actions=quit;
    DBusActivatable=true
    SingleMainWindow=true
    X-GNOME-UsesNotifications=true
    X-GNOME-SingleWindow=true
    
    [Desktop Action quit]
    Exec=/opt/Telegram.yz/Telegram -quit
    Name=Quit Telegram
    Icon=application-exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment