c++ld-preload

ERROR: ld.so: object '/opt/xyz/mylib.so' from LD_PRELOAD cannot be preloaded: ignored


After upgrading a software from 32 to 64-bit, a pre-compiled binary starts to fail with the error:

[root@localhost /root]# LD_PRELOAD=/opt/xyz/lib/mylib.so mycommand /inputfile.txt /outputfile.txt 
ERROR: ld.so: object '/opt/xyz/lib/mylib.so' from LD_PRELOAD cannot be preloaded: ignored.
mycommand: error while loading shared libraries: mylib.so: cannot open shared object file: No such file or directory

mycommand is a precompiled binary that sits in /usr/bin/mycommand. It requires the library as LD_PRELOAD.

Obviously I made sure that the file /opt/xyz/lib/mylib.so does exist:

[root@localhost lib]# ls -alh
total 512K
drwxr-xr-x  2 root root 4.0K Mar  1 15:40 .
drwxr-xr-x 10 root root 4.0K Feb 24 10:54 ..
-rwxr-xr-x  1 root root 218K Oct 28 22:41 mylib64.so
lrwxrwxrwx  1 root root   14 Mar  1 15:40 mylib.so -> mylib64.so

Is there any more debugging information I can extract other that this error? It seems like not relevant if I simply delete the mylib.so or not, the error stays the same. It's kind of hard to say if it can't preload the library or if it can't find the library.

Is there any other environment variables or libraries that are required for LD_PRELOAD to work?

It seems to me essential to acquire a version of the source code of the mycommand binary and re-compile it. However to do that I think it would be probably useful to see why it actually fails right now.


Solution

  • LD_PRELOAD will not work on symlinks. You will need to set the path to the actual location of the library. For example:

    LD_PRELOAD=/opt/xyz/lib/mylib64.so
    

    I agree that a more specific error message would've been useful.