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

Attempting to compile a 32 bit application on CentOS results in error

本文关键字:应用程序 错误 32位 编译 CentOS      更新时间:2023-10-16

所以我已经安装了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

我也有类似的问题,并且已经厌倦了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

此"i386"目录不是使用诸如之类的命令通过百胜安装的

yum install devtoolset-2

在x64 CentOS计算机上。

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

64位CentOS 6和devtoolset 1.1也存在类似问题。

32位库似乎安装在:中

/opt/centros/devtoolset-1.1/root/usr/lib/gcc/x86_64-redhat-linux/4.72/32

目录中的一些库与../../..中的文件符号链接/i686 redhat-linux/4.7.2/,它们不存在。

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

百胜安装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位应用程序。

我之前也遇到过类似的问题,我猜出了原因并找到了解决方案。

环境:

(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