知识屋:更实用的电脑技术知识网站
所在位置:首页 > 操作系统 > linux

./stdio.h:477:1: error: 'gets' undeclared here (not in a function)解决

发布时间:2014-09-05 13:48:54作者:知识屋

./stdio.h:477:1: error: 'gets' undeclared here (not in a function)解决
 
今天编译一个bsp包时,出现如下错误,简直不知道为嘛,按理说官方给的bsp包没什么问吧,但在ubuntu 13.4下编译,出现如标题的错误,于是只能google,问题是解决了
 
I hope you are all well.
 
Glibc-2.16.0 has been released
http://ftp.gnu.org/gnu/glibc/glibc-2.16.0.tar.xz
The good news is that it no longer needs the patches that are in
current LFS. However, there are still some problems with it. Firstly,
the libgcc_s.so
issue:
 
/mnt/lfs/tools/bin/../lib/gcc/x86_64-lfs-linux-gnu/4.7.1/../../../../x86_64-lfs-linux-gnu/bin/ld:
cannot find -lgcc_s
collect2: error: ld returned 1 exit status
make[2]: *** [/mnt/lfs/sources/glibc-build/iconv/iconv_prog] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory `/mnt/lfs/sources/glibc-2.16.0/iconv'
make[1]: *** [iconv/others] Error 2
make[1]: Leaving directory `/mnt/lfs/sources/glibc-2.16.0'
make: *** [all] Error 2
 
Fixed by:
sed -i 's# -lgcc_s##' Makeconfig
(We won't hit the libgcc_s.so problem with Gcc until we start using
Gcc-4.7.2)
Then an error due to a problem with gcc:
 
/mnt/lfs/sources/glibc-build/resolv/libresolv_pic.a(gethnamaddr.os): In function `getanswer':
/mnt/lfs/sources/glibc-2.16.0/resolv/gethnamaddr.c:180: undefined reference to `__stack_chk_guard'
/mnt/lfs/sources/glibc-2.16.0/resolv/gethnamaddr.c:483: undefined reference to `__stack_chk_guard'
/mnt/lfs/sources/glibc-build/resolv/libresolv_pic.a(gethnamaddr.os): In function `res_gethostbyaddr':
/mnt/lfs/sources/glibc-2.16.0/resolv/gethnamaddr.c:644: undefined reference to `__stack_chk_guard'
/mnt/lfs/sources/glibc-2.16.0/resolv/gethnamaddr.c:783: undefined reference to `__stack_chk_guard'
/mnt/lfs/sources/glibc-build/resolv/libresolv_pic.a(gethnamaddr.os): In function `__GI_res_gethostbyname2':
/mnt/lfs/sources/glibc-2.16.0/resolv/gethnamaddr.c:510: undefined reference to
`__stack_chk_guard'
/mnt/lfs/sources/glibc-build/resolv/libresolv_pic.a(gethnamaddr.os):/mnt/lfs/sources/glibc-2.16.0/resolv/gethnamaddr.c:636:
more undefined references to `__stack_chk_guard' follow
collect2: error: ld returned 1 exit status
make[2]: *** [/mnt/lfs/sources/glibc-build/resolv/libresolv.so] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory `/mnt/lfs/sources/glibc-2.16.0/resolv'
make[1]: *** [resolv/others] Error 2
make[1]: Leaving directory `/mnt/lfs/sources/glibc-2.16.0'
make: *** [all] Error 2
 
Fixed by this sed in the gcc source before the first pass of gcc:
 
sed -i '/k prot/agcc_cv_libc_provides_ssp=yes' gcc/configure
 
Then a simple problem with the rpc headers:
 
glibc-build/config.h rpc_tblout.c /
-o /mnt/lfs/sources/glibc-build/sunrpc/cross-rpc_tblout.o -MMD -MP -MF
/mnt/lfs/sources/glibc-build/sunrpc/cross-rpc_tblout.o.dt -MT
/mnt/lfs/sources/glibc-build/sunrpc/cross-rpc_tblout.o -c
rpc_clntout.c:34:23: fatal error: rpc/types.h: No such file or directory
compilation terminated.
make[2]: *** [/mnt/lfs/sources/glibc-build/sunrpc/cross-rpc_clntout.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory `/mnt/lfs/sources/glibc-2.16.0/sunrpc'
make[1]: *** [sunrpc/others] Error 2
make[1]: Leaving directory `/mnt/lfs/sources/glibc-2.16.0'
make: *** [all] Error 2
 
Fixed by:
sed -i 's#<rpc/types.h>#"rpc/types.h"#' sunrpc/rpc_clntout.c
 
There's lots of gets removal breakage.
diffutils-3.2 fails to build:
 
  CC       exitfail.o
In file included from exclude.c:31:0:
./stdio.h:1012:1: error: 'gets' undeclared here (not in a function)
  CC       file-type.o
  CC       filenamecat.o
  CC       filenamecat-lgpl.o
make[3]: *** [exclude.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[3]: Leaving directory `/mnt/lfs/sources/diffutils-3.2/lib'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/mnt/lfs/sources/diffutils-3.2/lib'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/mnt/lfs/sources/diffutils-3.2/lib'
make: *** [all-recursive] Error 1
 
Fixed with a sed:
sed -i '/gets is a security hole/d' lib/stdio.in.h
 
Gettext fails to build:
 
In file included from backupfile.c:25:0:
./stdio.h:456:1: error: 'gets' undeclared here (not in a function)
make[1]: *** [backupfile.lo] Error 1
make[1]: Leaving directory `/mnt/lfs/sources/gettext-0.18.1.1/gettext-tools/gnulib-lib'
make: *** [all] Error 2
make: Leaving directory `/mnt/lfs/sources/gettext-0.18.1.1/gettext-tools/gnulib-lib'
 
Fixed with a sed:
sed -i '/gets is a security hole/d' gnulib-lib/stdio.in.h(在源码中找到gnulib-lib)
 
M4 fails to build:
 
gcc -std=gnu99  -I.     -g -O2 -MT clean-temp.o -MD -MP -MF .deps/clean-temp.Tpo -c -o clean-temp.o clean-temp.c
In file included from clean-temp.h:22:0,
                 from clean-temp.c:23:
./stdio.h:477:1: error: 'gets' undeclared here (not in a function)
mv -f .deps/c-ctype.Tpo .deps/c-ctype.Po
gcc -std=gnu99  -I.     -g -O2 -MT close-hook.o -MD -MP -MF .deps/close-hook.Tpo -c -o close-hook.o close-hook.c
mv -f .deps/c-stack.Tpo .deps/c-stack.Po
gcc -std=gnu99  -I.     -g -O2 -MT execute.o -MD -MP -MF .deps/execute.Tpo -c -o execute.o execute.c
make[3]: *** [clean-temp.o] Error 1
make[3]: *** Waiting for unfinished jobs....
mv -f .deps/close-hook.Tpo .deps/close-hook.Po
mv -f .deps/execute.Tpo .deps/execute.Po
mv -f .deps/gl_avltree_oset.Tpo .deps/gl_avltree_oset.Po
make[3]: Leaving directory `/mnt/lfs/sources/m4-1.4.16/lib'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/mnt/lfs/sources/m4-1.4.16/lib'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/mnt/lfs/sources/m4-1.4.16'
make: *** [all] Error 2
 
Fixed with a sed:
sed -i '/gets is a security hole/d' lib/stdio.in.h
 
Tar fails to build:
In file included from argp.h:24:0,
                 from argp-eexst.c:27:
./stdio.h:479:1: error: 'gets' undeclared here (not in a function)
make[4]: *** [argp-eexst.o] Error 1
make[4]: *** Waiting for unfinished jobs....
In file included from argp-fmtstream.h:29:0,
                 from argp-fmtstream.c:35:
./stdio.h:479:1: error: 'gets' undeclared here (not in a function)
make[4]: *** [argp-fmtstream.o] Error 1
make[4]: Leaving directory `/mnt/lfs/sources/tar-1.26/gnu'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/mnt/lfs/sources/tar-1.26/gnu'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/mnt/lfs/sources/tar-1.26/gnu'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/mnt/lfs/sources/tar-1.26'
make: *** [all] Error 2
 
Fixed with a sed:
sed -i '/gets is a security hole/d' gnu/stdio.in.h
 
And so into chroot.
Glibc fails with the rpc/types.h error again. It seems crazy to me that
it tries to use the system header not the in-tree one but what do I
know?:
 
sed -i 's#<rpc/types.h>#"rpc/types.h"#' sunrpc/rpc_clntout.c
 
Again, the glibc patches are not needed.
test-installation.pl failed with an error:
 
test ! -x /sources/glibc-build/elf/ldconfig || LC_ALL=C LANGUAGE=C /
  /sources/glibc-build/elf/ldconfig  /
      /lib64 /usr/lib64
CC="gcc" /usr/bin/perl scripts/test-installation.pl /sources/glibc-build/
Unmatched ( in regex; marked by <-- HERE in m/$( <-- HERE if
$(abi-64-ld-soname),$(abi-64-ld-soname),ld/ at scripts/test-installation.pl line 172, <LDD>
line 1.
make[1]: *** [install] Error 29
make[1]: Leaving directory `/sources/glibc-2.16.0'
make: *** [install] Error 2
root:/sources/glibc-build# cd /sources/glibc-2.16.0
root:/sources/glibc-2.16.0# CC="gcc" /usr/bin/perl scripts/test-installation.pl /sources/glibc-build/
Unmatched ( in regex; marked by <-- HERE in m/$( <-- HERE if
$(abi-64-ld-soname),$(abi-64-ld-soname),ld/ at scripts/test-installation.pl line 172, <LDD>
line 1.
 
So I disabled running test-installation.pl:
sed -i '/test-installation.pl/d' Makefile
I'm sure there is a more subtle fix for this but I don't have time just
now.
 
And speaking of time; timezones. Timezone data are not part of glibc
anymore:
cp: cannot stat '/usr/share/zoneinfo/Europe/London': No such file or directory
 
I have to install a new package tzdata2012c
http://www.iana.org/time-zones:
 
for thing in etcetera southamerica northamerica europe africa antarctica /
  asia australasia backward pacificnew solar87 solar88 solar89 systemv
do zic -L /tmp/tzdata/leapseconds -d /share/zoneinfo /
    -y "sh ~/tzdata/yearistype.sh" /tmp/tzdata/${thing}
done
cp /usr/share/zoneinfo/Europe/London /etc/localtime
 
And then we're back to the gets breakage grind. M4, inetutils,
diffutils, gettext, grub, libpipeline, man-db and Tar all need
variations on the gets sed. Eg,for Gettext in chroot it's now:
 
sed -i '/gets is a security hole/d' /
    gettext-{runtime/gnulib-lib,tools/{gnulib-lib,libgettextpo}}/stdio.in.h
 
I should confess that (as I'm a devotee of the Klingon School of
Programming) I didn't run any of the tests, so there may be some more
bugs under those rocks.
 
Andy
(免责声明:文章内容如涉及作品内容、版权和其它问题,请及时与我们联系,我们将在第一时间删除内容,文章内容仅供参考)
收藏
  • 人气文章
  • 最新文章
  • 下载排行榜
  • 热门排行榜