温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

64位linux编译c提示gnu/stubs-32.h:No such file or directory错误怎么办

发布时间:2021-05-10 14:58:04 来源:亿速云 阅读:1031 作者:小新 栏目:编程语言

小编给大家分享一下64位linux编译c提示gnu/stubs-32.h:No such file or directory错误怎么办,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!

什么是Linux系统

Linux是一种免费使用和自由传播的类UNIX操作系统,是一个基于POSIX的多用户、多任务、支持多线程和多CPU的操作系统,使用Linux能运行主要的Unix工具软件、应用程序和网络协议。

64位linux提示gnu/stubs-32.h:No such file or directory的解决方法

这个问题是由于缺少32位兼容包,解决办法:

ubuntu: sudo apt-get install libc6-dev-i386

CentOS:yum -y install glibc-devel.i686

Re阿里云yum源没有glibc.i686

阿里云的64位Linux发行版屏蔽了32位,也就是常见的i686软件包的数据源,你可以修改yum的配置文件/etc/yum.conf,找到其中exclude=*.i?86 kernel kernel-xen kernel-debug,用#注释掉即可,但是阿里不赞成这么做,如果32位、64位混用,比较容易出问题。

今天在64位linux编译程序时,出现如下错误提示

/usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h:No such file or directory

解决方法如下

# yum -y install glibc-devel

场景描述:在编译程序的时候出现如下的错误:
make[1]: Entering directory `/root/rpmbuild/BUILD/test/conf'
In file included from /usr/include/features.h:385,
                 from /usr/include/stdint.h:26,
                 from ../include/MyTypes.h:4,
                 from conf_init.c:1:
/usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h: No such file or directory
make[1]: *** [conf_init32.o] Error 1
make[1]: Leaving directory `/root/rpmbuild/BUILD/test/conf'
make: *** [all] Error 1

解决过程:

1完全无法分析天书般的错误,英文非常简单,但是翻译非常困难,好在
/usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h: No such file or directory
这一句了解,好既然少这个文件,拷贝一个文件过来,OK解决问题。
2.经过老大的解决思路,看出端倪。
说明如下:conf_init.c:第一行引用../include/MyTypes.h头文件,
而这个头文件在第四行引用/usr/include/stdint.h头文件,
而这个头文件在第26行引用/usr/include/features.h头文件,
而这个头文件在第385行应用了/usr/include/gnu/stubs.h头文件,
而这个头文件在第7行引用了gnu/stubs-32.h头文件
然后在编译的过程中,没有发现这个文件。大体意思清楚没有。
下面是/usr/include/gnu/stubs.h文件的内容如下:

/* This file selects the right generated file of `__stub_FUNCTION' macros
  based on the architecture being compiled for. */

#include <bits/wordsize.h>

#if __WORDSIZE == 32
# include <gnu/stubs-32.h>
#elif __WORDSIZE == 64
# include <gnu/stubs-64.h>
#els
# error "unexpected value for __WORDSIZE macro"
#endif
~

注明:这个文件说明了64位或者32位编译环境选择的头文件。所以在编译的过程中,
使用了-m2的参数就会链接到32位版本的编译器,修改所有的Makefile文件,查看
是否有什么32位编译的删除即可。

查阅的外文资料几乎没有任何用处:
On Ubuntu it's called libc6-dev-i386 - do sudo apt-get install libc6-dev-i386. See below for extra instructions for Ubuntu 12.04.

On Red Hat distros, the package name is glibc-devel.i686 (Thanks to David Gardner's comment)

On CentOS 5.8, the package name is glibc-devel.i386 (Thanks to JimKleck's comment)

On CentOS 6.3, the package name is glibc-devel.i686.

On SLES it's called glibc-devel-32bit - do zypper in glibc-devel-32bit
在SLES系统上,执行上述指令安装,在/usr/include/gnu目录下确实生成了上述的文件。
在CentOS系统上,无效。

64位的机器上找不到32位的头文件。所以要安装glibc-devel.i686(redhat不同系统不太一样)

随手搜了一个rpm包,用rpm -ivh安装报错:(因为服务器不联外网,所以这么安装)

error:Failed dependencies

忽略依赖关系问题
rpm –nodeps -i 即可安装成功

cd /usr/include/gnu/下查看,文件stubs-32.h已经存在。解决问题。

下面是/usr/include/gnu/stubs.h文件的内容如下:

/* This file selects the right generated file of `__stub_FUNCTION' macros
based on the architecture being compiled for. */

include
if __WORDSIZE == 32
include
elif __WORDSIZE == 64
include
els
error “unexpected value for __WORDSIZE macro”
endif
~

看完了这篇文章,相信你对“64位linux编译c提示gnu/stubs-32.h:No such file or directory错误怎么办”有了一定的了解,如果想了解更多相关知识,欢迎关注亿速云行业资讯频道,感谢各位的阅读!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI