How to compile .so file in Ubuntu with GLIBC_2.27

I have an executable and some .so file in Ubuntu 20.04 but I need to use these .so files in Ubuntu 18.04. Now, when I try to copy and use these .so files in Ubuntu 18.04, it is giving me error which is /lib/x86_64-linux-gnu/libm.so.6: version GLIBC_2.29' not found (required by test.so).

I got to know that we cannot upgrade the GLIBC_2.27 on Ubuntu 18.04 to GLIBC_2.29. So, I want to try compiling the .so in Ubuntu 20.04 with GLIBC_2.27 Version to make it working with Ubuntu 18.04.

I have two questions now:-

(a) Is this kind of compilation possible?

(b) If possible, how to do that?


Solution 1:

You can copy these libraries to application folder app-folder and then adjust LD_LIBRARY_PATH variable on runtime as follows:

LD_LIBRARY_PATH=app-folder app-folder/your-app