gcc - 是否可以使用 gcc >= 8 在 CentOS 7 上编译 32 位目标?

标签 gcc centos 32-bit

我有一个需要在我的 64 位 CentOS 7 上编译为 32 位的应用程序。我使用 -m32为此标志。我还需要 c++17 的功能,所以我想安装 gcc 8.x。我发现devtoolset 8附带 gcc 8.2.1,这对我有好处。

应用程序编译正常,但问题在于链接 - 它找不到一些 32 位库:
[100%] Linking CXX executable cherrySim_runner /opt/rh/devtoolset-8/root/usr/libexec/gcc/x86_64-redhat-linux/8/ld: cannot find /usr/lib/libstdc++.so.6 /opt/rh/devtoolset-8/root/usr/libexec/gcc/x86_64-redhat-linux/8/ld: skipping incompatible /opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8/libstdc++_nonshared.a when searching for -lstdc++_nonshared /opt/rh/devtoolset-8/root/usr/libexec/gcc/x86_64-redhat-linux/8/ld: cannot find -lstdc++_nonshared /opt/rh/devtoolset-8/root/usr/libexec/gcc/x86_64-redhat-linux/8/ld: cannot find /lib/libgcc_s.so.1
我发现 devtoolset 准备了一些 32 位库,但这些是指向不存在路径的链接,例如:/opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8/32/libstdc++_nonshared.a -> ../../../i686-redhat-linux/8/libstdc++_nonshared.a .根本没有/opt/rh/devtoolset-8/root/usr/lib/gcc/i686-redhat-linux 目录。我尝试了几件事,但似乎没有任何效果。

我开始怀疑我正在尝试做的事情是否可能。

米哈乌

最佳答案

不幸的是,我发现在 CentOS 上没有包含 32 位版本 gcc > 8 的 gcc std 库的软件包。

我的 docker 镜像需要这个,但由于无法做到这一点,我切换到了 ubuntu i386 16.04,它可以非常轻松地安装 gcc 8.2。

关于gcc - 是否可以使用 gcc >= 8 在 CentOS 7 上编译 32 位目标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55278573/

相关文章:

windows - 所有 Windows 版本都支持 Int64 吗?

amazon-s3 - 如何在 amazon linux 2 或 centos 中将 s3fs 从 v1.74 更新到最新版本?

centos - 如何使用 Red Hat Developer Toolset 构建 32 位二进制文​​件?

c - 在 C 中减去无符号整数并得到 -Wconversion 警告

c - 找出由 `gcc hello_world.c -S` 生成的汇编语言类型

c++ - GCC C++ "Hello World"程序 -> .exe 在 Windows 上编译时为 500kb 大。我怎样才能减小它的大小?

c++ - 编译一个c工程到最小尺寸

linux - 将 SAN 存储共享路径附加到两台 linux 机器

php - 无法在 centos 6.8 上安装 php55 imagick 已安装 php-devel 但缺少

delphi - 如何使我的 32 位 Delphi 应用程序能够在 64 位 Windows 上使用 4GB 内存(通过 Wow64.exe)?