首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用构建32位二进制文件?

如何使用构建32位二进制文件?
EN

Stack Overflow用户
提问于 2020-02-14 16:03:30
回答 1查看 1.7K关注 0票数 1

我找不到任何关于如何使用定位32位的文档(在本例中是在CentOS 7上运行的版本9.0 )。新闻稿中提到:

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

它还在以下文件中提供了所需的32位库:

代码语言:javascript
复制
/opt/rh/devtoolset-9/root/usr/lib/gcc/x86_64-redhat-linux/9/32/

然而,建筑失败了。尝试构建最小int main() {}程序的示例:

代码语言:javascript
复制
$ 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

但是,它找不到的库实际上是存在的:

代码语言:javascript
复制
/opt/rh/devtoolset-9/root/usr/lib/gcc/x86_64-redhat-linux/9/32/libstdc++_nonshared.a

没有多少-L标志可以修复它(无论如何,它都是错误的解决方案;链接器甚至不应该试图在-m32模式下加载64位库)。

我在这里错过了什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-02-18 00:52:29

我想您没有注意到/opt/rh/devtoolset-9/root/usr/lib/gcc/x86_64-redhat-linux/9/32/libstdc++_nonshared.a很可能是一个悬空的符号链接:

代码语言:javascript
复制
$ 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显式验证)。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60229740

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档