1

I'm about to release a library (.so) to my client. However, my client's platform is a very old debian(9.1 released on 2017). My libray only works with >= glibc-2.27.
I managed to run program by the following tricks

// copy libm-2.27.so from my computer to the old debian
ln -sf ./libm-2.27.so libm.so.6
gcc ./test.c -o ./test -lmylib -L ./ -lm
LD_LIBRARY_PATH=`pwd` ./test

But my client don't accept this solution.
Is it possible to link to an older version of math library ?
For instance, the client gives me the math library and I link my library against it in my computer.

thanks!

prgbenz
  • 1,129
  • 4
  • 13
  • 27
  • Yes, that might work, but it's not very nice. If you do want to use the new version of libm you should statically link it instead. – Rup Feb 06 '20 at 10:51
  • But the best thing to do would be to build releases of your library for this customer on Debian 9.1 - e.g. set up a VM or Docker. There's a risk changing compiler or other parts of glib will cause problems though. – Rup Feb 06 '20 at 10:53
  • I have no luck on linking libm statically. I got this /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libm-2.27.a(e_atan2.o): relocation R_X86_64_PC32 against undefined symbol `_dl_x86_cpu_features' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: final link failed: Bad value collect2: error: ld returned 1 exit status – prgbenz Feb 06 '20 at 11:09
  • Is it possible to install a toolchain that match with that of debian 9 on my ubuntu 18.04 ? – prgbenz Feb 06 '20 at 11:15
  • Sorry, you're right about linking statically: I forgot you're building a library yourself. You can probably set up the existing Debian binaries in a chroot, or start with the GCC source and build a cross-compiler targeting the Debian libraries I guess? – Rup Feb 06 '20 at 11:33

1 Answers1

1

My libray only works with >= glibc-2.27.

Is it because you actually require functionality that was added to GLIBC-2.27, or because you system just happens to have that version installed and you don't know how to build for an older system?

From the comments, it appears that you don't actually need GLIBC-2.27.

In that case, the simplest solution is to install a VM with Debian 9.1 in it, and build you library inside that VM.

This has an added advantage that you can test your library before you ship it to your client, in the environment that matches that of the client.

If you do not want a VM, other solutions are listed here.

I managed to run program by the following tricks ... But my client don't accept this solution.

Your client is smart to reject that solution: it can not generally work, and running in such environment would expose your client to a multitude of potential undefined behaviors and crashes. To understand why this is so, read this answer.

Employed Russian
  • 199,314
  • 34
  • 295
  • 362