4

Is there any way to install a new version of GLIBC locally in a folder? I will be able to add its library paths to LD_LIBRARY_PATH later without interfering with the system libraries?.

I didn't find such solution. For me that means all system should be upgraded for this purpose which is not I want.

P.S: Someone stated something here, but without any detail.

Community
  • 1
  • 1
mahmood
  • 23,197
  • 49
  • 147
  • 242

2 Answers2

0

Is there any way to install a new version of GLIBC locally in a folder?

Yes, see this answer.

I will be able to add its library paths to LD_LIBRARY_PATH later without interfering with the system libraries?.

As the answer explains, you can't do that.

Community
  • 1
  • 1
Employed Russian
  • 199,314
  • 34
  • 295
  • 362
  • This is a good reference, but the answer does NOT tell that you can't use LD_LIBRARY_PATH. You can, but before that you need matching version of dynamic loader anyway. – Peter K Mar 24 '16 at 11:55
-1

Yes, you can do it; I'd advise to do it with the permissions of the ordinary user to not break the whole system accidentally. It should be easier to unpack the package manually and not use OS package setup tools.

Then you should be able to add the path to LD_LIBRARY_PATH and it should be preferred over the system lib dir. You can use ldd command to see what runtime libraries will actually be used. It should show no not found entries, if it does you are missing something.

You'll need some experiments to make it actually work, but in this way you will break one console session at a time, which you can easily restart. An alternative way might be a hardlinked chroot environment, but that looks as an overkill.

Peter K
  • 1,787
  • 13
  • 15
  • All I see on the internet recommend to use system package manager (yum or apt) which I don't prefer. Do you know the easy steps to build it manually? – mahmood Mar 16 '16 at 13:26
  • Yes, here is an official instruction: http://www.gnu.org/software/libc/manual/html_node/Configuring-and-compiling.html. My point was that you can just download your OS glibc package without installing it (with or without manager) and then unpack it manually, as that package is usually some form of archive. – Peter K Mar 16 '16 at 13:59
  • One more try: http://www.gnu.org/software/libc/manual/html_node/Configuring-and-compiling.html – Peter K Mar 16 '16 at 14:40
  • OK that is a comprehensive guide which explains all options. I don't know should I use binutils or not and bla bla... What are the default steps? I mean should I use `./configure` and `make`? – mahmood Mar 16 '16 at 14:49
  • Why do you want to build libc? Have you read the very first paragraph of that page? `configure` takes many options, but the only one that is usually mandatory is `--prefix`. The GNU C Library cannot be compiled in the source directory. So you should read that and then run $ `../glibc-version/configure --prefix=~/libc` and then `make` – Peter K Mar 16 '16 at 14:57
  • So, I just ran `mkdir built && cd built && ../configure --prefix=/opt/glibc/built && make`. I can now see the libc.so in `built/`. Is that all? should I now run `LD_LIBRARY_PATH=/opt/glibc/built`?? – mahmood Mar 16 '16 at 15:47
  • Almost: for it to work the `libc.so` should be in that directory: either run `make install` (`sudo make install`) or copy it there yourself. – Peter K Mar 16 '16 at 16:01
  • Although by specifying `--prefix`, it will install in the specified directory, I want to be sure that it really doesn't destroy current system! – mahmood Mar 16 '16 at 16:04
  • OK I ran `make install`. Previously, for the binary file I got `/lib64/libc.so.6: version 'GLIBC_2.14' not found (required by ./sfk)`. By setting `export LD_LIBRARY_PATH=/opt/glibc_2.16/built`, I get `error while loading shared libraries: __vdso_time: invalid mode for dlopen(): Invalid argument` – mahmood Mar 16 '16 at 16:19
  • Consider using `dynamic-linker` when building as outlined here: http://stackoverflow.com/questions/847179/multiple-glibc-libraries-on-a-single-host/851229#851229 – Peter K Mar 16 '16 at 17:24
  • That may work with source files. Unfortunately, for available binaries, things are all complicated :( – mahmood Mar 16 '16 at 18:41
  • We should probably move to chat, but have a link at this tool: https://nixos.org/patchelf.html - you can modify dynamic linker path in executable file, see also discussion here: http://unix.stackexchange.com/questions/122670/using-alternate-libc-with-ld-linux-so-hacks-cleaner-method – Peter K Mar 16 '16 at 18:46