centos7编译libiconv报错:./stdio.h:1010:1: error: 'gets' undeclared here (not in a function)
如题:配置编译参数通过,在进行 make 的时候报如下错误:
- 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[2]: *** [progname.o] Error 1
- make[2]: Leaving directory `/usr/local/src/zabbix-2.4.7/libiconv-1.14/srclib'
- make[1]: *** [all] Error 2
- make[1]: Leaving directory `/usr/local/src/zabbix-2.4.7/libiconv-1.14/srclib'
- make: *** [all] Error 2
解决方法:
使用 find 查找 stion.in.h 文件:
find / -name 'stdio.in.h'
编辑该文件
vim /usr/local/src/zabbix-2.4.7/libiconv-1.14/srclib/stdio.in.h
通过关键字 gets 找到698 行,将其和695行一同注释:
- 695 /* It is very rare that the developer ever has full control of stdin,
- 696 so any use of gets warrants an unconditional warning. Assume it is
- 697 always declared, since it is required by C89.
- 698 _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
保存退出!(注意#endif 下面还有一个 #endif):
#配置文件内容(如下)
#endif
#if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)
_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
#endif
重新编译即可!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?