C++ 试图在CentOS上编译32位应用程序时出错

C++ 试图在CentOS上编译32位应用程序时出错,c++,compilation,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+

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

我也有类似的问题,并且已经厌倦了devtoolset1、1.1和2,所有这些都有相同的结果。进一步研究,我在目录中看到:

/opt/centos/devtoolset-1.0/root/usr/lib/gcc/x86_64-CentOS-linux/4.7.0
有一个“32”目录,其中有一些库文件和指向另一个目录的链接,指示“i386”:

此“i386”目录不是使用以下命令使用yum安装的:

yum install devtoolset-2
在x64 CentOS机器上


因此,正如上面Zinglish所问的,如何在64位操作系统上通过yum安装32位库?我使用的是RPM源代码。

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中不存在的文件进行了符号链接

因此,我显式安装了devtoolset 32位库:

yum安装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++)
> tried to compile 32bit at 64bit linux machine(centos). However there
> was no appropriate g++ library.
问题:当我试图用Makefile编译.cpp和.h时,我在下面遇到了一个错误。

skipping incompatible .../libstdc++.so 
原因:

(centos6 x64 g++)
> 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

x86_64-redhat-linux
就在那里,您只安装了64位库,它无法使用。有没有办法安装32位libs?不确定这是否是最好的答案,但它对我很有效。我手动下载并安装了(rpm-ivh)devtoolset-2-libquadmath-devel-4.8.2-15.el5.i386.rpm devtoolset-2-libstdc++-devel-4.8.2-15.el5.i386.rpm,它将32位的库放置在正确的位置,这样我现在就可以使用devtools编译x64和x86了。您正在谈论的是centos6的标准gcc安装。OP讨论的是使用devtoolset提供的另一个编译器。