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

2017-10-12 21:53:16 +08:00
 jimy1

从 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
1083 次点击
所在节点    Go 编程语言
2 条回复
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
2017-10-13 10:00:35 +08:00
谢谢 changnet 深夜回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/397182

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX