Rootop 服务器运维与web架构

centos7下编译安装libiconv-1.14 error: ‘gets’ undeclared here (not in a function)

centos7下编译安装libiconv-1.14报错,信息如下:

In file included from progname.c:26:0:
./stdio.h:1010:1: error: ‘gets’ undeclared here (not in a function)
 _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
 ^
make[1]: *** [progname.o] Error 1
make[1]: Leaving directory `/root/lnmp1.2/source/libiconv-1.14/srclib'
make: *** [all] Error 2

解决方法:
编辑 libiconv-1.14/srclib/stdio.h 文件,这个文件在make之后才会生成,源码中是没有的。

1007 /* It is very rare that the developer ever has full control of stdin,
1008 so any use of gets warrants an unconditional warning. Assume it is
1009 always declared, since it is required by C89. */
1010 _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");

第1010行,把 _GL_WARN_ON_USE (gets, “gets is a security hole – use fgets instead”); 删掉
改为:

#if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)
_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
#endif

变成如下:

继续make && make install 通过

原创文章,转载请注明。本文链接地址: https://www.rootop.org/pages/3532.html

作者:Venus

服务器运维与性能优化

评论已关闭。