Search code examples
linuxpostgresqlmakefile

Is it possible to build PostgreSQL for multiple linux versions/distros at once?


I used to get the PostgreSQL binaries from EDB for Linux but after 11 it no longer has them (from here: https://www.enterprisedb.com/download-postgresql-binaries).

Because before this used to be possible and the download is independant of the Linux distro and version, I'm guessing there must be way.

Currently, I'm building PostgreSQL in Ubunutu 22.04 and then trying to use it on Ubuntu 20.04 as well as RHEL 7.9 and it won't work. I usually get missing .so files but now after inlcuding openssl I also get stuff like:

./initdb: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by ./initdb)

I got around the issues with the .so files by including them in the lib directory and then adding them as symlinks to the system lib folder but this one I can't seem to get around.

So my question is: Is there a way that I can reliably build PostgreSQL in a way that it is compatible with various versions and distributions of Linux such as Ubuntu 20, 22, RHEL, CentOS, etc?

Thanks in advance.

EDIT: Forgot to add that this is meant to be included on an offline installer so that is why I'm doing this as I can't rely on native repositories like apt or yum.


Solution

  • You have to build it on the OLDEST system you want to run on. Libraries like the C runtime library (libc) are backward-compatible (that is, newer versions work with code that was compiled against an older version) but they are not forward-compatible (that is, older versions won't work with code that was compiled against a newer version).

    If you don't want to do that, you'll need to create a new sysroot containing the oldest libraries you want to run with and configure your compiler to use that, instead of the standard libraries on the system. This is not simple but it's not rocket science.