fatal error: gnu/stubs-32.h: No such file or directory

在 64 位 CentOS 7 编译 32 位目标代码 gcc -m32 时遇到错误:

[code lang=text]
In file included from /usr/include/features.h:399:0,
from /usr/include/stdio.h:27,
from vuln.c:2:
/usr/include/gnu/stubs.h:7:27: fatal error: gnu/stubs-32.h: No such file or directory
# include <gnu/stubs-32.h>
^
compilation terminated.
[/code]

通过 yum install glibc-devel 解决时发现 Package glibc-devel-2.17-196.el7_4.2.x86_64 already installed and latest version

执行 yum install glibc-devel.i686 后再编译继续报错:

[code lang=text]
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.8.5/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
collect2: error: ld returned 1 exit status
[/code]

ld 找不到 gcc_s 库,定位一下:

[code lang=text]
# locate libgcc_s.so
/usr/lib/gcc/x86_64-redhat-linux/4.8.2/libgcc_s.so
/usr/lib/gcc/x86_64-redhat-linux/4.8.2/32/libgcc_s.so
/usr/lib64/libgcc_s.so.1
[/code]

发现 /usr/lib/gcc/x86_64-redhat-linux/4.8.2/32/libgcc_s.so 链接失效了:

链接失效

链接失效

解决方法就是再安装一个库 yum install libstdc++-devel.i686

参考链接:
Error “gnu/stubs-32.h: No such file or directory” while compiling Nachos source code
Build fails with ”fatal error: gnu/stubs-32.h: No such file or directory”. What is the problem?
64bit Linux CentOS 7下编译32bit程序的方法

如无特殊说明,文章均为本站原创,转载请注明出处
源自: 王明军的博客
本文链接地址: fatal error: gnu/stubs-32.h: No such file or directory
广告

Categories: 默认目录

Tagged as: , ,

发表评论

This site uses Akismet to reduce spam. Learn how your comment data is processed.