Centos 如何使用Red Hat Developer工具集构建32位二进制文件?

Centos 如何使用Red Hat Developer工具集构建32位二进制文件?,centos,g++,centos7,32-bit,devtoolset,Centos,G++,Centos7,32 Bit,Devtoolset,我找不到任何关于如何使用Red Hat Developer工具集(在本例中为9.0版,在CentOS 7上运行)以32位为目标的文档。发行说明提到: 还支持生成和操作32位二进制文件 它还提供所需的32位库: /opt/rh/devtoolset-9/root/usr/lib/gcc/x86_64-redhat-linux/9/32/ 然而,建筑失败了。尝试构建最小int main(){}程序的示例: $ scl enable devtoolset-9 'g++ -m32 tst.cpp' /

我找不到任何关于如何使用Red Hat Developer工具集(在本例中为9.0版,在CentOS 7上运行)以32位为目标的文档。发行说明提到:

还支持生成和操作32位二进制文件

它还提供所需的32位库:

/opt/rh/devtoolset-9/root/usr/lib/gcc/x86_64-redhat-linux/9/32/
然而,建筑失败了。尝试构建最小
int main(){}
程序的示例:

$ scl enable devtoolset-9 'g++ -m32 tst.cpp'
/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: skipping incompatible /opt/rh/devtoolset-9/root/usr/lib/gcc/x86_64-redhat-linux/9/libstdc++_nonshared.a when searching for -lstdc++_nonshared
/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: cannot find -lstdc++_nonshared
collect2: error: ld returned 1 exit status
它找不到的库实际上存在,但:

/opt/rh/devtoolset-9/root/usr/lib/gcc/x86_64-redhat-linux/9/32/libstdc++_nonshared.a
没有任何数量的
-L
标志可以修复它(无论如何,这将是错误的解决方案;链接器甚至不应该尝试在
-m32
模式下加载64位库。)


我在这里遗漏了什么?

我猜您没有注意到
/opt/rh/devtoolset-9/root/usr/lib/gcc/x86_64-redhat-linux/9/32/libstdc++\u非共享。a
很可能是一个悬挂的符号链接:

$ file /opt/rh/devtoolset-9/root/usr/lib/gcc/x86_64-redhat-linux/9/32/libstdc++_nonshared.a
/opt/rh/devtoolset-9/root/usr/lib/gcc/x86_64-redhat-linux/9/32/libstdc++_nonshared.a: broken symbolic link to `../../../i686-redhat-linux/9/libstdc++_nonshared.a'
$ 

但遗憾的是,任何CentOS软件包都没有提供目标文件
/opt/rh/devtoolset-9/root/usr/lib/gcc/i686 redhat linux/9/libstdc++.a
(但它应该位于
devtoolset-9-libstdc++-devel.i686
)。因此,可能是CentOS特定的打包错误,因为为Red Hat Enterprise Linux 7提供了受质疑的包
devtoolset-9-libstdc++-devel-9.1.1-2.6.el7.i686.rpm
,其中包含所需的文件(在RHEL 7上通过yum install/opt/rh/devtoolset-9/root/usr/lib/gcc/i686 redhat linux/9/libstdc++_nonshared.a进行明确验证).

Dang it。你说得对。回到Ubuntu 16.04,然后构建我的发行版二进制文件。不确定它是否适用于你的特定用例,但有一个。谢谢,但我不使用这样的锁定系统。当我需要它们时,它们可能会因为帐户问题、DRM问题或其他原因而关闭并无法访问。我需要一些我能做到的东西依靠工作。