ldd does not find path, How to add

76,303

Solution 1

if your libraries are not on standard path then either you need to add them to the path or add non-standard path to LD_LIBRARY_PATH

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<Your_non-Standard_path>

Once you done any one of above things then you need to update the dynamic linker run-time binding by executing below command:

sudo ldconfig

UPDATE:

You can make the changes permanent by either writing the above export line into one of your startup files (e.g. ~/.bashrc) OR if the underlying library is not conflicting with any other library then put into one of standard library path (e.g. /lib,/usr/lib)

Solution 2

LD_LIBRARY_PATH is suitable for short tests, but since there is only one variable, it is awkward to use when you might have multiple applications with custom libraries.

The usual way for Debian/Ubuntu is to add it to the loader's configuration, e.g., a file under

/etc/ld.so.conf.d

containing the directory in which you want the loader to search, e.g.,

/usr/local/libcsfml

Further reading:

Solution 3

This looks as if the binary in question was compiled by you.

So you are responsible for the problem that some libraries cannot be found.

In case that these libraries are available on your system, they seem to be located in non-standard directory locations.

Use -R directory for the final compiler call to tell the linker the directory where the libraries are located. More than a single -R directory option is possible.

Note that when you are using gcc, you may need to use -Wl,-R instead of -R.

Share:
76,303

Related videos on Youtube

C-Jay
Author by

C-Jay

Updated on September 18, 2022

Comments

  • C-Jay
    C-Jay over 1 year

    I know this question isn't very new but it seems as if I didn't be able to fix my problem on myself.

    ldd generate the following output

    u123@PC-Ubuntu:~$ ldd /home/u123/Programme/TestPr/Debug/TestPr
        linux-vdso.so.1 =>  (0x00007ffcb6d99000)
        libcsfml-window.so.2.2 => not found
        libcsfml-graphics.so.2.2 => not found
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fcebb2ed000)
        /lib64/ld-linux-x86-64.so.2 (0x0000560c48984000)
    

    Which is the correct way to tell ld the correct path?

    • Alen Milakovic
      Alen Milakovic about 8 years
      You're asking the wrong question, imo. Use one of the existing paths that the linker knows about. See stackoverflow.com/a/10526145/350713. So, try running ldconfig -v 2>/dev/null | grep -v ^$'\t'. An obvious choice is /usr/local/lib if your linker knows about it. What is your distribution? And where are those libraries currently located? In any case, you should be able to install the binary packages you need to satisfy the linker.
    • C-Jay
      C-Jay almost 8 years
      running the cmake for sfml has done the job
  • MADforFUNandHappy
    MADforFUNandHappy over 6 years
    This worked for me with the libnode.so library bundled with the electron framework, I was wondering whether this might lead to conflicts ? What if there is already a lib called libnode.so ?
  • Marius
    Marius over 6 years
    Technically different libraries with the same filename could have different soname values (in that case, ldconfig might accept both), but if they have the same soname and/or symbols, it won't be that cooperative.
  • Petrus Theron
    Petrus Theron about 5 years
    So should /etc/ld.so.conf.d be a text file with a list of absolute paths?
  • Marius
    Marius about 5 years
    no - it's a directory, under which there are files containing lists of absolute paths.