ldd does not find path, How to add
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:
- ldconfig - configure dynamic linker run-time bindings
- ld.so, ld-linux.so* - dynamic linker/loader
- Why LD_LIBRARY_PATH is bad
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
.
Related videos on Youtube
C-Jay
Updated on September 18, 2022Comments
-
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 outputu123@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 about 8 yearsYou'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 almost 8 yearsrunning the cmake for sfml has done the job
-
-
MADforFUNandHappy over 6 yearsThis 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 over 6 yearsTechnically 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 about 5 yearsSo should /etc/ld.so.conf.d be a text file with a list of absolute paths?
-
Marius about 5 yearsno - it's a directory, under which there are files containing lists of absolute paths.