1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to Solve Linux Error When Loading Libraries

Discussion in 'Linux' started by lionaneesh, May 22, 2011.

  1. lionaneesh

    lionaneesh Active Member

    Joined:
    Mar 21, 2010
    Messages:
    848
    Likes Received:
    224
    Trophy Points:
    43
    Occupation:
    Student
    Location:
    India
    If you have some experience as a Linux Admin or Even if you are using linux , at some point of time you'll face a "Linux Error while Loading libraries" it seems something like

    error while loading shared libraries: *.so: cannot open shared object file: No such file or directory

    I faced this problem today while compiling an open source app! The problem was a pain for me! but after some time i came up with a pretty easy solution!

    Note: The Solution is tested on Backtrack and Ubuntu

    Solution



    First of all compile the application in this case i'll be compiling notSPIKEfile , So lets get just download it and get started

    Compile it :-
    Code:
    root@bt:~/notSPIKEfile# ./make.sh 
    gcc -I.  -O3 -ggdb -fPIC -shared -Wl,-soname,libdisasm.so libdis.c i386_invariant.c i386.c -o libdisasm.so
    libdis.c:3: warning: built-in function ‘exp’ declared as non-function
    libdis.c: In function ‘sprint_op’:
    libdis.c:232: warning: format ‘%X’ expects type ‘unsigned int’, but argument 4 has type ‘long int’
    libdis.c:232: warning: format ‘%X’ expects type ‘unsigned int’, but argument 4 has type ‘long int’
    libdis.c:234: warning: format ‘%X’ expects type ‘unsigned int’, but argument 4 has type ‘long unsigned int’
    libdis.c:234: warning: format ‘%X’ expects type ‘unsigned int’, but argument 4 has type ‘long unsigned int’
    i386_invariant.c: In function ‘disasm_invariant_decode’:
    i386_invariant.c:146: warning: incompatible implicit declaration of built-in function ‘memcpy’
    i386_invariant.c: In function ‘disasm_invariant’:
    i386_invariant.c:208: warning: incompatible implicit declaration of built-in function ‘memcpy’
    gcc -I.  -O3 -ggdb -L. -ldisasm quikdis.c -o quikdis
    gcc -I.  -O3 -ggdb -L. -ldisasm testdis.c -o testdis
    gcc notSPIKEfile.o fuzz_utils.o signal_utils.o ptrace_utils.o -o notSPIKEfile libdisasm/src/arch/i386/libdisasm/libdisasm.so
    
    Now lets try and run the application :-
    Code:
    root@bt:~/notSPIKEfile# ./notSPIKEfile 
    ./notSPIKEfile: error while loading shared libraries: libdisasm.so: cannot open shared object file: No such file or directory
    
    Now we need to add "root//notSPIKEfile/libdisasm/src/arch/i386/libdisasm/libdisasm.so" path to LD_LIBRARY_PATH (environment variable)..

    Lets do that :-
    Code:
    root@bt:~/notSPIKEfile# export LD_LIBRARY_PATH=`pwd`libdisasm/src/arch/i386/libdisasm/
    
    Lets run the app now :-

    Code:
    root@bt:~/notSPIKEfile# ./notSPIKEfile 
    Missing arguments.
    notSPIKEfile
        notSPIKEfile [options] <base file> <command>
    
    
    Required Options:
    
     -o    Output file name base for fuzzed files
    
    Additional Options:
    
     -t    Timeout value (default=2)
     -k    Do not kill the process after timeout
     -s    Send the specified signal to kill the process. Default is SIGTERM, some apps need SIGKILL
     -h    Print this message
     -m    Maximum concurrent processes (default=1)
     -r    Fuzz this range of bytes in stead of trying the whole file (format low-high)
     -f    Fuzz this range of fuzz values in stead of using all known fuzz values (format low-high)
     -B    Blob mode (replace with blobs)
     -S    String mode (replace with fancy strings)
     -d    Delay between kill and re-exec (default=1)
    
    Command:
    
        Quoted command to execute to process the generated file.
        Use %FILENAME% as a symbol to be replaced with the filename.
        If %FILENAME% is absent in the command string, filename will be appended automatically
    
    
    Example:
    
    notSPIKEfile -t 3 -d 1 -m 6 -r 30- -s SIGKILL -o FUZZY.gif test.gif "/usr/bin/display -debug %FILENAME%"
    
    root@bt:~/notSPIKEfile# ./notSPIKEfile 
    
    That's it ... Problem fixed!
    Lets get back to work!
     
  2. lionaneesh

    lionaneesh Active Member

    Joined:
    Mar 21, 2010
    Messages:
    848
    Likes Received:
    224
    Trophy Points:
    43
    Occupation:
    Student
    Location:
    India
    Thanks for accepting my article! Stay tuned for more!
     

Share This Page