我找不到任何关于如何使用定位32位的文档(在本例中是在CentOS 7上运行的版本9.0 )。新闻稿中提到:
还支持生成和操作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位库)。
我在这里错过了什么?
发布于 2020-02-18 00:52:29
我想您没有注意到/opt/rh/devtoolset-9/root/usr/lib/gcc/x86_64-redhat-linux/9/32/libstdc++_nonshared.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'
$ 然而,不幸的是,目标文件/opt/rh/devtoolset-9/root/usr/lib/gcc/i686-redhat-linux/9/libstdc++_nonshared.a没有由任何CentOS包提供(但它应该在devtoolset-9-libstdc++-devel.i686中)。因此,这可能是特定于CentOS的打包错误,因为土卫五-2019:4134为RedHatEnterpriseLinux7提供了受质疑的包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显式验证)。
https://stackoverflow.com/questions/60229740
复制相似问题