源碼編譯安裝 libiconv-1.14 報:./stdio.h:1010:1: error: ‘gets’ undeclared here (not in a function) [


轉自:http://www.linuser.com/thread-1482-1-1.html


如題:配置編譯參數通過,在進行 make 的時候報如下錯誤:

  1. In file included from progname.c:26:0:
  2. ./stdio.h:1010:1: error: ‘gets’ undeclared here (not in a function)
  3. _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
  4. ^
  5. make[2]: *** [progname.o] Error 1
  6. make[2]: Leaving directory `/usr/local/src/zabbix-2.4.7/libiconv-1.14/srclib'
  7. make[1]: *** [all] Error 2
  8. make[1]: Leaving directory `/usr/local/src/zabbix-2.4.7/libiconv-1.14/srclib'
  9. make: *** [all] Error 2
復制代碼


解決方法:

使用 find 查找 stion.in.h 文件:

  1. [root@ip-172-31-29-70 libiconv-1.14]# find / -name 'stdio.in.h'
復制代碼


編輯該文件

  1. [root@ip-172-31-29-70 libiconv-1.14]# vim /usr/local/src/zabbix-2.4.7/libiconv-1.14/srclib/stdio.in.h
復制代碼

通過關鍵字 gets 找到698 行,將其和695行一同注釋:

  1. 695 /* It is very rare that the developer ever has full control of stdin,
  2. 696    so any use of gets warrants an unconditional warning.  Assume it is
  3. 697    always declared, since it is required by C89.
  4. 698 _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");*/
復制代碼

然后再注釋的行下面添加以下三行:

  1. #if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)
  2. _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
  3. #endif
復制代碼

保存退出!(注意#endif 下面還有一個 #endif):

重新編譯即可!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM