温馨提示×

温馨提示×

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

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

编译glibc遇到的错误 Error: invalid identifier for ".ifdef"怎么解决

发布时间:2021-06-22 14:22:34 来源:亿速云 阅读:386 作者:chen 栏目:大数据

本篇内容介绍了“编译glibc遇到的错误 Error: invalid identifier for ".ifdef"怎么解决”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

由于CentOS6系统默认的glibc版本较低,在尝试编译升级时遇到了Error: invalid identifier for ".ifdef",在此记录解决方案。

编译安装

官网下载:ftp://ftp.gnu.org/gnu/glibc/

下载并编译安装

wget http://ftp.gnu.org/gnu/glibc/glibc-2.15.tar.gz
wget http://ftp.gnu.org/gnu/glibc/glibc-ports-2.15.tar.gz
tar -zxf glibc-2.15.tar.gz
tar -zxf glibc-ports-2.15.tar.gz
mv glibc-ports-2.15 glibc-2.15/ports
mkdir glibc-build-2.15
cd glibc-build-2.15
../glibc-2.15/configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin
make all && make install

解决错误

sysdeps/i386/fpu/s_frexp.S:66: Error: invalid identifier for ".ifdef"

1.修改文件pt-initfini.c

在glibc源码目录下找到文件 nptl/sysdeps/pthread/pt-initfini.c,约在46行左右:asm ("\n#include \"defs.h\"");

在其后增加代码:

asm ("\n#if defined __i686 && defined __ASSEMBLER__");
asm ("\n#undef __i686");
asm ("\n#define __i686 __i686");
asm ("\n#endif");

2.修改文件sysdep.h

在glibc源码目录下找到文件 sysdeps/unix/sysv/linux/i386/sysdep.h ,约在30行左右:#include <tls.h>

在其后增加代码:

#if defined __i686 && defined __ASSEMBLER__
#undef __i686
#define __i686 __i686
#endif

3.重新编译

make all && make install

判断当前GLIBC版本

ldd --version

如下则成功安装 

ldd (GNU libc) 2.15
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

“编译glibc遇到的错误 Error: invalid identifier for ".ifdef"怎么解决”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!

向AI问一下细节

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

AI