/usr/bin/ld: warning: abc.so, needed by xyz.so not found (try using -rpath or -rpath-link)"

oompahloompah picture oompahloompah · Feb 6, 2011 · Viewed 10.5k times · Source

I am building a C++ application, using Netbeans 6.9 as my IDE. I have a C++ library which is a wrapper around a pure C library.

I have correctly added the file to the project (using the Add Library File option). Here is the output produced by g++ and the linker:

g++  -o dist/Debug/GNU-Linux-x86/testluaembed build/Debug/GNU-Linux-x86/src/main.o build/Debug/GNU-Linux-x86/src/LuaBinding.o -L../../mainline/tanlib_core/dist/Debug/GNU-Linux-x86 -L../../mainline/tanlib++/dist/Debug/GNU-Linux-x86 -L/usr/lib ../../mainline/tanlib_core/dist/Debug/GNU-Linux-x86/libtanlib_core.so ../../mainline/tanlib++/dist/Debug/GNU-Linux-x86/libtanlibpp.so /usr/lib/liblua5.1.a /usr/lib/libtolua++5.1.a /usr/local/boost_1_45_0/stage/lib/libboost_filesystem.a /usr/local/boost_1_45_0/stage/lib/libboost_system.a 
/usr/bin/ld: warning: libtanlib_core.so, needed by ../../mainline/tanlib++/dist/Debug/GNU-Linux-x86/libtanlibpp.so, not found (try using -rpath or -rpath-link)
/usr/lib/liblua5.1.a(loadlib.o): In function `ll_loadfunc':
/usr/lib/liblua5.1.a(loadlib.o): In function `ll_loadfunc':
/usr/lib/liblua5.1.a(loadlib.o): In function `ll_loadfunc':
/usr/lib/liblua5.1.a(loadlib.o): In function `ll_loadfunc':
/usr/lib/liblua5.1.a(loadlib.o): In function `gctm':
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/GNU-Linux-x86/testluaembed] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

I run ldd on the C++ wrapper library and got this output:

$ldd libtanlibpp.so 
    linux-vdso.so.1 =>  (0x00007fff123c0000)
    libtanlib_core.so => not found
    libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007fe4f0fde000)
    libm.so.6 => /lib/libm.so.6 (0x00007fe4f0d5a000)
    libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00007fe4f0b43000)
    libc.so.6 => /lib/libc.so.6 (0x00007fe4f07c0000)
    /lib64/ld-linux-x86-64.so.2 (0x00007fe4f15ee000)

So although the file exists on my machine, it appears it is not in my library cache. I tried using ldconfig, but the problem remains. Any ideas on how to resolve this?

Answer

Dmitry Yudakov picture Dmitry Yudakov · Feb 6, 2011

Make sure the directory where libtanlib_core.so is placed is configured in /etc/ld.so.conf (or /etc/ld.so.conf.d/) - otherwise ldconfig will not find it.