1

I Have Libraries with a tree of dependencies, i.e. some of the dependencies have other dependencies I want to Preload. How can I do this?

LD_PRELOAD \
/opt/yocto/2.5.1/sysroots/core2-64-poky-linux/usr/lib/libicudata.so.60 \
/opt/yocto/2.5.1/sysroots/core2-64-poky-linux/usr/lib/libicuuc.so.60 \
/opt/yocto/2.5.1/sysroots/core2-64-poky-linux/usr/lib/libicui18n.so.60 \
/opt/yocto/2.5.1/sysroots/core2-64-poky-linux/usr/lib/libQt5Core.so.5 \
MyApp

The LD_PRELOAD call contains is sorted, such that the dependencies are listed before the depending library.

The Linker throws the following error:

ERROR: ld.so: object '/opt/yocto/2.5.1/sysroots/core2-64-poky-linux/usr/lib/libQt5Core.so.5' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.

Can the libraries be preloaded to fulfil the dependencies in the correct order?

danba
  • 842
  • 11
  • 32

1 Answers1

1

This error:

ld.so: object '/opt/yocto/2.5.1/sysroots/core2-64-poky-linux/usr/lib/libQt5Core.so.5' \
from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.

means that the dynamic loader tried to open the library and failed.

There are several possible reasons for this failure:

  1. The file doesn't exist (use ls -L /opt/yocto/2.5.1/sysroots/core2-64-poky-linux/usr/lib/libQt5Core.so.5 to confirm that it does
  2. The file is for the wrong architecture (e.g. 32-bit ELF when MyApp is 64-bit, or vice versa). Use file MyApp and file libQt5Core.so.5 to confirm that they match.
  3. Something else. Perhaps MyApp was linked with newlib or uClibc, but libQt5Core.so.5 was built with GLIBC (or vice versa).
Employed Russian
  • 199,314
  • 34
  • 295
  • 362
  • In my case the library can't be preloaded because it itself requires a dynamic library which is "not found" in the LD_LIBRARY_PATH. Unfortunate I can't change the LD_LIBRARY_PATH to include the dependencies. – danba Nov 16 '18 at 06:12
  • @danba I am confused: if you know the reason `libQt5Core` is not loading, why didn't you say so, and why don't you add whatever library it requires to the `LD_PRELOAD` list? – Employed Russian Nov 16 '18 at 06:45
  • I was trying to explain that the shared Library is missing dependencies in the question. The LD_PRELOAD list in the question does contain all dependencies, they're just not interpreted correctly it seems. – danba Nov 16 '18 at 06:58
  • 1
    @danba Your theory of why this doesn't work is probably incorrect. How do you *know* that "the library can't be preloaded because it itself requires a dynamic library which is "not found"" ? Setting `LD_DEBUG=files,libs` could provide additional info. – Employed Russian Nov 16 '18 at 15:06
  • Thanks for the `LD_DEBUG=files,libs` suggestion. It turns out the environment was dirty on that machine. Your answer, by the way, summarizes possible issues nicely. – danba Nov 19 '18 at 13:13