V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
The Go Programming Language
http://golang.org/
Go Playground
Go Projects
Revel Web Framework
jimy1
V2EX  ›  Go 编程语言

请教交叉编译报错: libgcc_s.so.1: 版本`GCC_4.2.0'未找到(文件 helloworld 必需的) -- /tank/obsnew/lib/libgcc_s.so.1: 错误的 ELF 类型: ELFCLASS32

  •  
  •   jimy1 · 2017-10-12 21:53:16 +08:00 · 1084 次点击
    这是一个创建于 2600 天前的主题,其中的信息可能已经有所发展或是发生改变。

    从 Linux 64 位( Redhat 6.5 )交叉编译生成 Solaris 5.10 目标可执行程序,golang 语言打印一个 hello world,先从 Solaris 拷贝了头文件和库文件到红帽,再编译 binutils,再编译 gcc-5.1.0,生成 sparc-sun-solaris2.10-gccgo

    拷贝到 Solaris 后执行报错:

    t5240-1:/tank/obsnew/yinq/shandonglt% ./helloworld
    ld.so.1: helloworld: 致命的: libgcc_s.so.1: 版本`GCC_4.2.0'未找到(文件 helloworld 必需的)
    ld.so.1: helloworld: 致命的: /tank/obsnew/lib/libgcc_s.so.1: 错误的 ELF 类型:ELFCLASS32
    被杀掉
    

    ldd 和 Solarisgcc 版本:

    t5240-1:/tank/obsnew/yinqq/lt% ldd aiReqResend
    		libnsl.so.1 =>   /lib/64/libnsl.so.1
    		libsocket.so.1 =>        /lib/64/libsocket.so.1
    		librt.so.1 =>    /lib/64/librt.so.1
    		libpthread.so.1 =>       /lib/64/libpthread.so.1
    		libm.so.2 =>     /lib/64/libm.so.2
    		libgcc_s.so.1 =>         /usr/local/lib/sparcv9/libgcc_s.so.1
    		libgcc_s.so.1 (GCC_4.2.0) =>     (version not found)
    		libc.so.1 =>     /lib/64/libc.so.1
    		libmp.so.2 =>    /lib/64/libmp.so.2
    		libmd.so.1 =>    /lib/64/libmd.so.1
    		libscf.so.1 =>   /lib/64/libscf.so.1
    		libaio.so.1 =>   /lib/64/libaio.so.1
    		libdoor.so.1 =>  /lib/64/libdoor.so.1
    		libuutil.so.1 =>         /lib/64/libuutil.so.1
    		libgen.so.1 =>   /lib/64/libgen.so.1
    		/platform/SUNW,T5240/lib/sparcv9/libc_psr.so.1
    		/platform/SUNW,T5240/lib/sparcv9/libmd_psr.so.1
    t5240-1:/tank/obsnew/yinqq/lt% file /usr/local/lib/sparcv9/libgcc_s.so.1
    /usr/local/lib/sparcv9/libgcc_s.so.1: ELF 64-bit MSB dynamic library SPARCV9 version 1,dynamic linked,not striped
    t5240-1:/tank/obsnew/yinq/shandonglt% gcc -v
    Reading specs from /usr/local/lib/gcc/sparc-sun-solaris2.10/3.4.6/specs
    Configured with: ../configure --with-as=/usr/ccs/bin/as --with-ld=/usr/ccs/bin/ld --enable-shared --enable-languages=c,c++,f77
    Thread model: posix
    gcc version 3.4.6
    

    编译过程:

    [y@M610-252126 aiReqResend]$ go build --compiler gccgo --gccgoflags "-v -static-libgo -Wl,-dy -lnsl -lsocket -lrt" aiReqResend.go
    # parsing_config
    Using built-in specs.
    COLLECT_GCC=gccgo
    Target: sparc-sun-solaris2.10
    Configured with: ../gcc-5.1.0/configure --target=sparc-sun-solaris2.10 --with-gnu-as --with-gnu-ld --prefix=/home/y/opt/cross/ --with-sysroot=/home/y/opt/cross/sysroot/ --disable-libgcj --enable-languages=c,c++,go
    Thread model: posix
    gcc version 5.1.0 (GCC) 
    COLLECT_GCC_OPTIONS='-I' '/tmp/go-build137487689' '-c' '-g' '-m64' '-fgo-pkgpath=parsing_config' '-fgo-relative-import-path=_/home/y/xsd_log_resend/src/parsing_config' '-o' '/tmp/go-build137487689/parsing_config/_obj/_go_.o' '-v' '-shared-libgcc'
     /home/y/opt/cross/libexec/gcc/sparc-sun-solaris2.10/5.1.0/go1 ../parsing_config/parsing_config.go -mptr64 -mstack-bias -mno-v8plus -mcpu=v9 -quiet -dumpbase parsing_config.go -m64 -auxbase-strip $WORK/parsing_config/_obj/_go_.o -g -version -fgo-pkgpath=parsing_config -fgo-relative-import-path=_/home/y/xsd_log_resend/src/parsing_config -I $WORK -L/home/y/opt/cross/lib/gcc/sparc-sun-solaris2.10/5.1.0/sparcv9 -L/home/y/opt/cross/lib/gcc/sparc-sun-solaris2.10/5.1.0/../../../../sparc-sun-solaris2.10/lib/sparcv9 -L/home/y/opt/cross/sysroot/lib/sparcv9 -L/home/y/opt/cross/sysroot/usr/lib/sparcv9 -L/home/y/opt/cross/lib/gcc/sparc-sun-solaris2.10/5.1.0 -L/home/y/opt/cross/lib/gcc/sparc-sun-solaris2.10/5.1.0/../../../../sparc-sun-solaris2.10/lib -L/home/y/opt/cross/sysroot/lib -L/home/y/opt/cross/sysroot/usr/lib -o /tmp/ccJntC1m.s
    GNU Go (GCC) version 5.1.0 (sparc-sun-solaris2.10)
    	compiled by GNU C version 4.4.7 20120313 (Red Hat 4.4.7-4), GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1
    GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
    GNU Go (GCC) version 5.1.0 (sparc-sun-solaris2.10)
    	compiled by GNU C version 4.4.7 20120313 (Red Hat 4.4.7-4), GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1
    GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
    COLLECT_GCC_OPTIONS='-I' '/tmp/go-build137487689' '-c' '-g' '-m64' '-fgo-pkgpath=parsing_config' '-fgo-relative-import-path=_/home/y/xsd_log_resend/src/parsing_config' '-o' '/tmp/go-build137487689/parsing_config/_obj/_go_.o' '-v' '-shared-libgcc'
     /home/y/opt/cross/lib/gcc/sparc-sun-solaris2.10/5.1.0/../../../../sparc-sun-solaris2.10/bin/as -v -I $WORK -V -Qy -s -xarch=v9 -64 -no-undeclared-regs -o $WORK/parsing_config/_obj/_go_.o /tmp/ccJntC1m.s
    GNU assembler version 2.25 (sparc-sun-solaris2.10) using BFD version (GNU Binutils) 2.25
    COMPILER_PATH=/home/y/opt/cross/libexec/gcc/sparc-sun-solaris2.10/5.1.0/:/home/y/opt/cross/libexec/gcc/sparc-sun-solaris2.10/5.1.0/:/home/y/opt/cross/libexec/gcc/sparc-sun-solaris2.10/:/home/y/opt/cross/lib/gcc/sparc-sun-solaris2.10/5.1.0/:/home/y/opt/cross/lib/gcc/sparc-sun-solaris2.10/:/home/y/opt/cross/lib/gcc/sparc-sun-solaris2.10/5.1.0/../../../../sparc-sun-solaris2.10/bin/
    LIBRARY_PATH=/home/y/opt/cross/lib/gcc/sparc-sun-solaris2.10/5.1.0/sparcv9/:/home/y/opt/cross/lib/gcc/sparc-sun-solaris2.10/5.1.0/../../../../sparc-sun-solaris2.10/lib/sparcv9/:/home/y/opt/cross/sysroot/lib/sparcv9/:/home/y/opt/cross/sysroot/usr/lib/sparcv9/:/home/y/opt/cross/lib/gcc/sparc-sun-solaris2.10/5.1.0/:/home/y/opt/cross/lib/gcc/sparc-sun-solaris2.10/5.1.0/../../../../sparc-sun-solaris2.10/lib/:/home/y/opt/cross/sysroot/lib/:/home/y/opt/cross/sysroot/usr/lib/
    COLLECT_GCC_OPTIONS='-I' '/tmp/go-build137487689' '-c' '-g' '-m64' '-fgo-pkgpath=parsing_config' '-fgo-relative-import-path=_/home/y/xsd_log_resend/src/parsing_config' '-o' '/tmp/go-build137487689/parsing_config/_obj/_go_.o' '-v' '-shared-libgcc'
    # command-line-arguments
    Using built-in specs.
    COLLECT_GCC=gccgo
    Target: sparc-sun-solaris2.10
    Configured with: ../gcc-5.1.0/configure --target=sparc-sun-solaris2.10 --with-gnu-as --with-gnu-ld --prefix=/home/y/opt/cross/ --with-sysroot=/home/y/opt/cross/sysroot/ --disable-libgcj --enable-languages=c,c++,go
    Thread model: posix
    gcc version 5.1.0 (GCC) 
    COLLECT_GCC_OPTIONS='-I' '/tmp/go-build137487689' '-I' '/home/y/xsd_log_resend/pkg/gccgo_linux_amd64' '-c' '-g' '-m64' '-fgo-relative-import-path=_/home/y/xsd_log_resend/src/aiReqResend' '-o' '/tmp/go-build137487689/command-line-arguments/_obj/_go_.o' '-v' '-shared-libgcc'
     /home/y/opt/cross/libexec/gcc/sparc-sun-solaris2.10/5.1.0/go1 ./aiReqResend.go -mptr64 -mstack-bias -mno-v8plus -mcpu=v9 -quiet -dumpbase aiReqResend.go -m64 -auxbase-strip $WORK/command-line-arguments/_obj/_go_.o -g -version -fgo-relative-import-path=_/home/y/xsd_log_resend/src/aiReqResend -I $WORK -I /home/y/xsd_log_resend/pkg/gccgo_linux_amd64 -L/home/y/opt/cross/lib/gcc/sparc-sun-solaris2.10/5.1.0/sparcv9 -L/home/y/opt/cross/lib/gcc/sparc-sun-solaris2.10/5.1.0/../../../../sparc-sun-solaris2.10/lib/sparcv9 -L/home/y/opt/cross/sysroot/lib/sparcv9 -L/home/y/opt/cross/sysroot/usr/lib/sparcv9 -L/home/y/opt/cross/lib/gcc/sparc-sun-solaris2.10/5.1.0 -L/home/y/opt/cross/lib/gcc/sparc-sun-solaris2.10/5.1.0/../../../../sparc-sun-solaris2.10/lib -L/home/y/opt/cross/sysroot/lib -L/home/y/opt/cross/sysroot/usr/lib -o /tmp/ccy4Riqt.s
    GNU Go (GCC) version 5.1.0 (sparc-sun-solaris2.10)
    	compiled by GNU C version 4.4.7 20120313 (Red Hat 4.4.7-4), GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1
    GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
    GNU Go (GCC) version 5.1.0 (sparc-sun-solaris2.10)
    	compiled by GNU C version 4.4.7 20120313 (Red Hat 4.4.7-4), GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1
    GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
    COLLECT_GCC_OPTIONS='-I' '/tmp/go-build137487689' '-I' '/home/y/xsd_log_resend/pkg/gccgo_linux_amd64' '-c' '-g' '-m64' '-fgo-relative-import-path=_/home/y/xsd_log_resend/src/aiReqResend' '-o' '/tmp/go-build137487689/command-line-arguments/_obj/_go_.o' '-v' '-shared-libgcc'
     /home/y/opt/cross/lib/gcc/sparc-sun-solaris2.10/5.1.0/../../../../sparc-sun-solaris2.10/bin/as -v -I $WORK -I /home/y/xsd_log_resend/pkg/gccgo_linux_amd64 -V -Qy -s -xarch=v9 -64 -no-undeclared-regs -o $WORK/command-line-arguments/_obj/_go_.o /tmp/ccy4Riqt.s
    GNU assembler version 2.25 (sparc-sun-solaris2.10) using BFD version (GNU Binutils) 2.25
    COMPILER_PATH=/home/y/opt/cross/libexec/gcc/sparc-sun-solaris2.10/5.1.0/:/home/y/opt/cross/libexec/gcc/sparc-sun-solaris2.10/5.1.0/:/home/y/opt/cross/libexec/gcc/sparc-sun-solaris2.10/:/home/y/opt/cross/lib/gcc/sparc-sun-solaris2.10/5.1.0/:/home/y/opt/cross/lib/gcc/sparc-sun-solaris2.10/:/home/y/opt/cross/lib/gcc/sparc-sun-solaris2.10/5.1.0/../../../../sparc-sun-solaris2.10/bin/
    LIBRARY_PATH=/home/y/opt/cross/lib/gcc/sparc-sun-solaris2.10/5.1.0/sparcv9/:/home/y/opt/cross/lib/gcc/sparc-sun-solaris2.10/5.1.0/../../../../sparc-sun-solaris2.10/lib/sparcv9/:/home/y/opt/cross/sysroot/lib/sparcv9/:/home/y/opt/cross/sysroot/usr/lib/sparcv9/:/home/y/opt/cross/lib/gcc/sparc-sun-solaris2.10/5.1.0/:/home/y/opt/cross/lib/gcc/sparc-sun-solaris2.10/5.1.0/../../../../sparc-sun-solaris2.10/lib/:/home/y/opt/cross/sysroot/lib/:/home/y/opt/cross/sysroot/usr/lib/
    COLLECT_GCC_OPTIONS='-I' '/tmp/go-build137487689' '-I' '/home/y/xsd_log_resend/pkg/gccgo_linux_amd64' '-c' '-g' '-m64' '-fgo-relative-import-path=_/home/y/xsd_log_resend/src/aiReqResend' '-o' '/tmp/go-build137487689/command-line-arguments/_obj/_go_.o' '-v' '-shared-libgcc'
    # command-line-arguments
    Using built-in specs.
    COLLECT_GCC=gccgo
    COLLECT_LTO_WRAPPER=/home/y/opt/cross/libexec/gcc/sparc-sun-solaris2.10/5.1.0/lto-wrapper
    Target: sparc-sun-solaris2.10
    Configured with: ../gcc-5.1.0/configure --target=sparc-sun-solaris2.10 --with-gnu-as --with-gnu-ld --prefix=/home/y/opt/cross/ --with-sysroot=/home/y/opt/cross/sysroot/ --disable-libgcj --enable-languages=c,c++,go
    Thread model: posix
    gcc version 5.1.0 (GCC) 
    COMPILER_PATH=/home/y/opt/cross/libexec/gcc/sparc-sun-solaris2.10/5.1.0/:/home/y/opt/cross/libexec/gcc/sparc-sun-solaris2.10/5.1.0/:/home/y/opt/cross/libexec/gcc/sparc-sun-solaris2.10/:/home/y/opt/cross/lib/gcc/sparc-sun-solaris2.10/5.1.0/:/home/y/opt/cross/lib/gcc/sparc-sun-solaris2.10/:/home/y/opt/cross/lib/gcc/sparc-sun-solaris2.10/5.1.0/../../../../sparc-sun-solaris2.10/bin/
    LIBRARY_PATH=/home/y/opt/cross/lib/gcc/sparc-sun-solaris2.10/5.1.0/sparcv9/:/home/y/opt/cross/lib/gcc/sparc-sun-solaris2.10/5.1.0/../../../../sparc-sun-solaris2.10/lib/sparcv9/:/home/y/opt/cross/sysroot/lib/sparcv9/:/home/y/opt/cross/sysroot/usr/lib/sparcv9/:/home/y/opt/cross/lib/gcc/sparc-sun-solaris2.10/5.1.0/:/home/y/opt/cross/lib/gcc/sparc-sun-solaris2.10/5.1.0/../../../../sparc-sun-solaris2.10/lib/:/home/y/opt/cross/sysroot/lib/:/home/y/opt/cross/sysroot/usr/lib/
    COLLECT_GCC_OPTIONS='-o' 'aiReqResend' '-m64' '-v' '-shared-libgcc'
     /home/y/opt/cross/libexec/gcc/sparc-sun-solaris2.10/5.1.0/collect2 -plugin /home/y/opt/cross/libexec/gcc/sparc-sun-solaris2.10/5.1.0/liblto_plugin.so -plugin-opt=/home/y/opt/cross/libexec/gcc/sparc-sun-solaris2.10/5.1.0/lto-wrapper -plugin-opt=-fresolution=/tmp/cccfnQ4K.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc --sysroot=/home/y/opt/cross/sysroot/ -V -m elf64_sparc_sol2 -Y P,/home/y/opt/cross/sysroot//lib/sparcv9:/home/y/opt/cross/sysroot//usr/lib/sparcv9 -Qy -o aiReqResend /home/y/opt/cross/lib/gcc/sparc-sun-solaris2.10/5.1.0/sparcv9/crt1.o /home/y/opt/cross/sysroot/usr/lib/sparcv9/crti.o /home/y/opt/cross/sysroot/usr/lib/sparcv9/values-Xa.o /home/y/opt/cross/lib/gcc/sparc-sun-solaris2.10/5.1.0/sparcv9/crtbegin.o -L/home/y/opt/cross/lib/gcc/sparc-sun-solaris2.10/5.1.0/sparcv9 -L/home/y/opt/cross/lib/gcc/sparc-sun-solaris2.10/5.1.0/../../../../sparc-sun-solaris2.10/lib/sparcv9 -L/home/y/opt/cross/sysroot/lib/sparcv9 -L/home/y/opt/cross/sysroot/usr/lib/sparcv9 -L/home/y/opt/cross/lib/gcc/sparc-sun-solaris2.10/5.1.0 -L/home/y/opt/cross/lib/gcc/sparc-sun-solaris2.10/5.1.0/../../../../sparc-sun-solaris2.10/lib -L/home/y/opt/cross/sysroot/lib -L/home/y/opt/cross/sysroot/usr/lib $WORK/command-line-arguments/_obj/_go_.o -( $WORK/libparsing_config.a -E -) -dy -lnsl -lsocket -lrt -lgobegin -Bstatic -lgo -Bdynamic -lpthread -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc -lc /home/y/opt/cross/lib/gcc/sparc-sun-solaris2.10/5.1.0/sparcv9/crtend.o /home/y/opt/cross/sysroot/usr/lib/sparcv9/crtn.o
    GNU ld (GNU Binutils) 2.25
      Supported emulations:
       elf32_sparc_sol2
       elf32_sparc
       elf64_sparc_sol2
       elf64_sparc
    [y@M610-252126 aiReqResend]$ ll
    total 8168
    -rwxrwxr-x 1 y y 8350856 Oct 12 19:45 aiReqResend
    -rw-rw-r-- 1 y y 8610 Oct  9 15:14 aiReqResend.go
    
    2 条回复    2017-10-13 10:00:35 +08:00
    changnet
        1
    changnet  
       2017-10-12 23:43:40 +08:00
    libgcc_s.so.1 (GCC_4.2.0) => (version not found) 说明了对应版本的 so 库找不到。你的系统存在 libgcc_s.so.1 这个库,但与编译 aiReqResend 这个程序时的版本(4.2.0)不兼容。

    你应该在当前系统重新编译一次这个程序,或者把 4.2.0 版本的拷过来共存(即使能用也有可能存在未知的问题)
    jimy1
        2
    jimy1  
    OP
       2017-10-13 10:00:35 +08:00
    谢谢 changnet 深夜回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   4131 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 05:26 · PVG 13:26 · LAX 21:26 · JFK 00:26
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.