Command to build executable:
g++ -I../include/redis -L../lib/redis redis.cpp -o redis -lhiredis
Description:
I have libhiredis.so
in ../lib/redis/
. And in /usr/local/lib/hiredis13/
, there are libhiredis.so
and libhiredis.so.0.13
, this libhiredis.so
is a symbol link to libhiredis.so.0.13
.Then I ldd redis
, here is the result:
linux-vdso.so.1 => (0x00007ffd227f7000)
libhiredis.so.0.13 => not found
libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007f7ebca0d000)
libm.so.6 => /lib64/libm.so.6 (0x00007f7ebc70b000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f7ebc4f5000)
libc.so.6 => /lib64/libc.so.6 (0x00007f7ebc132000)
/lib64/ld-linux-x86-64.so.2 (0x00007f7ebcd23000)
Gcc should link to libhiredis.so
in ../lib/redis/
, am I right?
Probably your library has a SONAME
( libhiredis.so.0.13
) so the program records it instead of the name of the file. Then, in runtime, that SONAME
is searched for in the usual directories.
Your library is in /usr/local/lib/hiredis13/
, and that is not a usual directory. The solution is one of the following:
/usr/local/lib/hiredis13
directory in /etc/ld.so.conf
or /etc/ld.so.conf.d/*
and re-run ldconfig
. LD_LIBRARY_PATH=/usr/local/lib/hiredis13
when running the program. -rpath
linker option.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.