我有一个需要在我的 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/