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

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

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.

通过 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 后再编译继续报错:

/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

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

# 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

发现 /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程序的方法

Advertisements

分类:默认目录

Tagged as: , ,

发表评论

Fill in your details below or click an icon to log in:

WordPress.com 徽标

You are commenting using your WordPress.com account. Log Out /  更改 )

Google+ photo

You are commenting using your Google+ account. Log Out /  更改 )

Twitter picture

You are commenting using your Twitter account. Log Out /  更改 )

Facebook photo

You are commenting using your Facebook account. Log Out /  更改 )

Connecting to %s

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