Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

A few years ago I tried to compile a C++ project into a static binary which would work on both Ubuntu and CentOS.

Long story short, it wasn't possible. Because the latest versions of Ubuntu and CentOS at the time used different versions of glibc which were mutually incompatible.



If you statically link, it doesn't matter what version of glibc is on the target machine, because it's not used.


You would think so, but it's not true. I struggled with this for a few days before giving up (after finding articles which stated that this is really going where nobody went before)

> Static linking of glibc is not supported on Red Hat Enterprise Linux.

https://developers.redhat.com/blog/2016/02/17/upgrading-the-...


I don't pretend to know a lot about linking files, but I just checked an old static ffmbc binary I had lying around

  :/tmp$ file ffmbc 
    ffmbc: ELF 64-bit LSB  executable, x86-64, version 1 (SYSV), 
  statically linked, for GNU/Linux 2.6.15, BuildID[sha1]=...., stripped
  :/tmp$ ldd ffmbc 
	not a dynamic executable
 
It runs on the following libc versions:

  ldd (GNU libc) 2.12 (Centos 6.9)
  ldd (Ubuntu EGLIBC 2.19-0ubuntu6.14) 2.19 (ubuntu 14.04)
  ldd (Ubuntu GLIBC 2.23-0ubuntu10) 2.23 (Ubuntu 16.04)
I'm fairly sure it ran on distributions as old as ubuntu 8.04


You're supposed to bundle a fixed version of glibc with your application.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: