ranlib: error while loading shared libraries: libc.so.6: ELF file OS ABI invalid

Discussion in 'General Linux' started by Hemtarce, May 27, 2014.

  1. Hemtarce

    Hemtarce New Member

    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    hi all:
    I'm making cross-compile gcc, it's a compiler running on centos 6.0 and can build sources to generate codes runing on arm board. I have successful built(configure-make-make install) binutils and libc.
    build binutils on centos use gcc 4.4.7
    build libc on centos use arm-linux-gcc 4.6.0

    in the last stage, it's building gcc for arm on centos gcc 4.4.7.
    configure is ok
    make all is ok
    make install faild.

    make install error log:
    //-----------------------------------------------------------------------------------------------------------------
    ( cd /home/lianhua/arm-linux/4.6.0/arm-linux/4.6.0/arm-linux/lib/`/home/lianhua/arm-linux/4.6.0/build/gcc2/./gcc/xgcc -B/home/lianhua/arm-linux/4.6.0/build/gcc2/./gcc/ -B/home/lianhua/arm-linux/4.6.0/arm-linux/4.6.0/arm-linux/bin/ -B/home/lianhua/arm-linux/4.6.0/arm-linux/4.6.0/arm-linux/lib/ -isystem /home/lianhua/arm-linux/4.6.0/arm-linux/4.6.0/arm-linux/include -isystem /home/lianhua/arm-linux/4.6.0/arm-linux/4.6.0/arm-linux/sys-include -g -O2 -print-multi-os-directory` ; chmod 644 ./libiberty.an; /home/lianhua/arm-linux/4.6.0/arm-linux/4.6.0/arm-linux/bin/ranlib ./libiberty.an )
    /home/lianhua/arm-linux/4.6.0/arm-linux/4.6.0/arm-linux/bin/ranlib: error while loading shared libraries: libc.so.6: ELF file OS ABI invalid
    //====================================================================

    copy make install log as single terminal commands, and run these commands in terminal to test what's going on.
    test 1:
    cd /home/lianhua/arm-linux/4.6.0/arm-linux/4.6.0/arm-linux/lib
    /home/lianhua/arm-linux/4.6.0/arm-linux/4.6.0/arm-linux/bin/ranlib -v

    failed just as cross-compile gcc make install:
    //-----------------------------------------------------------------------------------------------------------------/home/lianhua/arm-linux/4.6.0/arm-linux/4.6.0/arm-linux/bin/ranlib: error while loading shared libraries: libc.so.6: ELF file OS ABI invalid
    //====================================================================
    this time, even running ls command is failed:
    ls: error while loading shared libraries: librt.so.1: ELF file OS ABI invalid

    there are 2 libc.so.6 in centos, one in /lib is for local, another in "/home/lianhua/arm-linux/4.6.0/arm-linux/4.6.0/arm-linux/lib" is for arm.
    ls -l /lib/libc.so.6
    lrwxrwxrwx 1 root root 12 May 19 13:58 /lib/libc.so.6 -> libc-2.12.so

    ls -l /home/lianhua/arm-linux/4.6.0/arm-linux/4.6.0/arm-linux/lib/libc.so.6
    lrwxrwxrwx 1 lianhua lianhua 12 May 28 00:10 /home/lianhua/***/lib/libc.so.6 -> libc-2.13.so

    file -L /lib/libc-2.12.so
    /lib/libc-2.12.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (GNU/Linux), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not stripped

    file -L /home/lianhua/arm-linux/4.6.0/arm-linux/4.6.0/arm-linux/lib/libc-2.13.so
    /home/lianhua/arm-linux/4.6.0/arm-linux/4.6.0/arm-linux/lib/libc-2.13.so: ELF 32-bit LSB shared object, ARM, version 1, dynamically linked (uses shared libs), for GNU/Linux 2.6.38, not stripped


    i think running ranlib failed because which loaded wring so file, right so file is /lib/libc.so.6, not /home/lianhua/***/lib/libc.so.6, so next test2.

    test2:
    cd /home/lianhua/arm-linux/4.6.0/arm-linux/4.6.0/arm-linux/lib
    export LD_LIBRARY_PATH=
    then ls is ok
    run:
    cd /home/lianhua/arm-linux/4.6.0/arm-linux/4.6.0/arm-linux/lib
    /home/lianhua/arm-linux/4.6.0/arm-linux/4.6.0/arm-linux/bin/ranlib -v
    result: failed
    /home/lianhua/arm-linux/4.6.0/arm-linux/4.6.0/arm-linux/bin/ranlib: error while loading shared libraries: libc.so.6: ELF file OS ABI invalid

    mv /home/lianhua/arm-linux/4.6.0/arm-linux/4.6.0/arm-linux/lib/libc.so.6 /home/lianhua/arm-linux/4.6.0/arm-linux/4.6.0/arm-linux/lib/_libc.so.6

    run ranlib again:
    cd /home/lianhua/arm-linux/4.6.0/arm-linux/4.6.0/arm-linux/lib
    /home/lianhua/arm-linux/4.6.0/arm-linux/4.6.0/arm-linux/bin/ranlib -v
    GNU ranlib (GNU Binutils) 2.22
    Copyright 2011 Free Software Foundation, Inc.
    This program is free software; you may redistribute it under the terms of
    the GNU General Public License version 3 or (at your option) any later version.
    This program has absolutely no warranty.

    it's ok.

    so, i think there are 2 libc.so.6, which all in LD_LIBRARY_PATH, when run ranlib, /home/lianhua/***/lib/libc.so.6 is searched first, maybe it's so close to ranlib, or maybe /home/lianhua/***/lib is in front of /lib in searching order, i'm not sure.

    test 3:
    cd /home/lianhua/arm-linux/4.6.0/arm-linux/4.6.0/arm-linux/lib
    /home/lianhua/arm-linux/4.6.0/arm-linux/4.6.0/arm-linux/bin/ranlib ./libiberty.an
    there are no error log.

    test 4:
    run make install, failed again as same as before and /home/lianhua/***/lib/libc.so.6 is created again.
    i think, when begin to make install, libc.so.6 is firstly created in /home/lianhua/***/lib, then running ranlib failed.

    how can runlib with /lib/lib.so.6, withnot a wrong one, i need change configure params and which one? or modify env variables?
    any advise is appreciated, thanks.
  2. ryanvade

    ryanvade Administrator Staff Member Staff Writer

    Messages:
    1,341
    Likes Received:
    447
    Trophy Points:
    83
    Can you force runlib to use the correct libc? Shouldn't libc be built with the same version of gcc as binutils?

Share This Page