Saturday, July 16, 2011

ldd shows "CANNOT FIND" for wrong archive lib or share

  • This particular linking problem means that your application is trying to load some of the library during time or may be at compile time and it is not able to get, because the current library path that is defined for linking scope doesn't have the file thatit wants may be it is in different directory that linker is not able to get.
    
    
    If a binary or a shared object that is built with archive members that are not in the LIBPATH, the archive members or shared objects that are not found will cause the error of "Cannot find" shown for the incorrect archive or shared obeject that really has been found in the output instead of listing the entries that haven't been found after the "Cannot find" message.
    
    As an example:
    
    
    # ldd libnetsnmpagent.so
    
    
    libnetsnmpagent.so needs:
    
    
    /usr/vacpp/lib/libnetsnmp.so.15(shr.o) 
    /usr/vacpp/lib/libnetsnmp.so.15(ansi_32.o)
             /usr/lib/libpthreads.a(shr_comm.o)
             /usr/lib/libpthreads.a(shr_xpg5.o)
             /usr/lib/threads/libc.a(shr.o) 
    Cannot find      /usr/lib/libc_r.a(shr.o) 
    /usr/vacpp/lib/libcrypto(ansicore_32.o)
             /usr/vacpp/lib/libC.a(shrcore.o)
             /usr/vacpp/lib/libC.a(shr2.o)
             /usr/vacpp/lib/libC.a(shr3.o)
             /unix
             /usr/lib/libcrypt.a(shr.o)
    
    
    
    
    
    
    If you do the following it will be found:
    
    
    
    
    # export LIBPATH=. <or path to where .a or .so are present>
    
    
    
    
    # ldd bad.so libnetsnmpagent.so needs:
    
    
    /usr/vacpp/lib/libnetsnmp.so.15(shr.o) 
    /usr/vacpp/lib/libnetsnmp.so.15(ansi_32.o) /usr/lib/libpthreads.a(shr_comm.o)
             /usr/lib/libpthreads.a(shr_xpg5.o)
             /usr/lib/threads/libc.a(shr.o)
             ./dpclcol.so
             /usr/lib/libc_r.a(shr.o)
             /usr/vacpp/lib/libC.a(ansicore_32.o)
             /usr/vacpp/lib/libC.a(shrcore.o)
             /usr/vacpp/lib/libC.a(shr2.o)
             /usr/vacpp/lib/libC.a(shr3.o)
             /unix
             /usr/lib/libcrypt.a(shr.o)
    
    
    -----------------------------------
    Tip:
    -----------------------------------
    What I used to do to deal with this situations is I used to write a script that I used to execute once the session is opened. Itsaves time and also effort to execute the command every time. Here is sample format of the script that you can find from here

No comments:

Post a Comment