Search code examples
c++clinuxld

Application running on Iinux OS (custom board) does not reads the shared libraries from the exported LD_LIBRARY_PATH


I am trying to run an application (a.out), very small application contains only one print statement) on Linux OS custom board which is not having the shared libs in /lib or /usr/lib.

So I am exporting the shared libs path using LD_LIBRARY_PATH

export LD_LIBRARY_PATH=/media/opensourcelib/toolchainLib/ramfslib

I made sure, shared libraries are in this path /media/opensourcelib/toolchainLib/ramfslib

Still, after this, when I execute a.out I get the error

/bin/sh: ./../usr/lib/a.out: not found

If I copy my shared libs to /lib, the application works fine.

But I need to make it work without copying the shared libs. Please help me, what could be the issue in exporting LD_LIBRARY_PATH.


Solution

  • I would do the following things:

    1. Check that the path is correct. Maybe an uppercase or lowercase letter or any other misspelling mistake. Try ls /media/opensourcelib/toolchainLib/ramfslib, before any other thing, and check that the library is there.
    2. Check that the necessary soft links exist into the path for the LD_LIBRARY_PATH. This is one of the things that do ldconfig. Maybe for your libmylib.so.1.5.8 you will find the links libmylib.so.1.5, libmylib.so.1 and libmylib.so.
    3. Check the library dependencies with ldd a.out.
    4. If you have strace installed into the system (if not, I recommend to compile it for your board and copy it to your board), try to launch it exporting previously LD_LIBRARY_PATH and verify the paths are tried to read (and a many other things).

    I hope it could be helpful.