尝试在CentOS上编译32位应用程序会导致错误

时间:2014-10-19 13:04:17

标签: c++ compilation

所以我安装了devtools,但我猜我的libstdc ++库不是正确的版本或不是32位?尝试编译时出现此错误。我该如何解决这个问题?

/opt/centos/devtoolset-1.1/root/usr/libexec/gcc/x86_64-redhat-linux/4.7.2/ld: skipping incompatible /opt/centos/devtoolset-1.1/root/usr/lib/gcc/x86_64-redhat-linux/4.7.2/libstdc++_nonshared.a when searching for -lstdc++_nonshared
/opt/centos/devtoolset-1.1/root/usr/libexec/gcc/x86_64-redhat-linux/4.7.2/ld: cannot find -lstdc++_nonshared

3 个答案:

答案 0 :(得分:1)

我有类似的问题,厌倦了devtoolset 1,1.1和2,都有相同的结果。进一步研究这个我在目录中看到:

/opt/centos/devtoolset-1.0/root/usr/lib/gcc/x86_64-CentOS-linux/4.7.0

有一个“32”目录,这里有一些库文件和指向另一个目录的链接,表示“i386”:

libitm.a -> ../../../i386-CentOS-linux/4.7.0/libitm.a
libitm.so
libquadmath.a -> ../../../i386-CentOS-linux/4.7.0/libquadmath.a
libquadmath.so
libstdc++.a -> ../../../i386-CentOS-linux/4.7.0/libstdc++.a
libstdc++_nonshared.a -> ../../../i386-CentOS-linux/4.7.0/libstdc++_nonshared.a
libstdc++.so
libsupc++.a

使用yum使用如下命令安装此“i386”目录:

yum install devtoolset-2
在x64 CentOS机器上。

正如上面的Zinglish所问,32位库如何在yum的64位操作系统上安装?我正在使用http://people.centos.org/tru/devtools-2作为RPM源。

答案 1 :(得分:1)

与64位CentOS 6和devtoolset 1.1类似的问题。

似乎安装了32位库:

  

/opt/centos/devtoolset-1.1/root/usr/lib/gcc/x86_64-redhat-linux/4.7.2/32

目录中的某些库符号链接到../../../i686-redhat-linux/4.7.2/中的文件,这些文件不存在。

所以我明确安装了devtoolset 32​​位库:

  

yum install devtoolset-1.1。* i686

但不知怎的,它们安装在/opt/rh/devtoolset-1.1/root/usr/lib/gcc/i686-redhat-linux/4.7.2/所以手动将目录符号链接到所需的位:

  

ln -s /opt/rh/devtoolset-1.1/root/usr/lib/gcc/i686-redhat-linux /opt/rh/devtoolset-1.1/root/usr/lib/gcc /.

最后成功编译了32位应用程序。

答案 2 :(得分:0)

之前我遇到过类似的问题,我想是一个理由并找到了解决方案。

环境:

(centos6 x64 g++)

问题:当我尝试使用Makefile编译.cpp和.h时,我遇到了错误..

skipping incompatible .../libstdc++.so 

原因:

> tried to compile 32bit at 64bit linux machine(centos). However there
> was no appropriate g++ library.

解决方案:安装libstdc ++

yum list *stdc*
yum install libstdc++-devel.i686
相关问题