问题解决:error: #error “Please port gnulib fseterr.c to your platform! Look at the definitions of ferror

一、遇到的问题:

编译Hi518EV300 LiteOS 时遇到如下问题:
lib/fseterr.c: In function 'fseterr':
lib/fseterr.c:77:3: error: #error "Please port gnulib fseterr.c to your platform! Look at the definitions of ferror and clearerr on your system, then report this to bug-gnulib."

lib/fseeko.c: In function 'fseeko':
lib/fseeko.c:77:3: error: #error "Please port gnulib fseeko.c to your platform! Look at the definitions of ferror and clearerr on your system, then report this to bug-gnulib."

二、网上的这种解决方法不能解决以上问题

进入文件对应的目录,执行下面的语句:
sed -i 's/IO_ftrylockfile/IO_EOF_SEEN/' lib/*.c
echo "#define _IO_IN_BACKUP 0x100" >> lib/stdio-impl.h

再次make还是会报错

三、正确的解决方法:打补丁

1. 解决fseek.c报错

/Hi3516EV200_SDK_V5.0.1.1/osdrv/tools/pc/hi_gzip/路径下,新建一个patch文件(补丁文件),比如:ll.patch(后缀是.patch即可)
ll.patch文件中填入以下内容,然后保存退出,这样补丁文件就有了。

From 4af4a4a71827c0bc5e0ec67af23edef4f15cee8e Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Mon, 5 Mar 2018 10:56:29 -0800
Subject: [PATCH] fflush: adjust to glibc 2.28 libio.h removal
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
 
Problem reported by Daniel P. Berrangé in:
https://lists.gnu.org/r/bug-gnulib/2018-03/msg00000.html
* lib/fbufmode.c (fbufmode):
* lib/fflush.c (clear_ungetc_buffer_preserving_position)
(disable_seek_optimization, rpl_fflush):
* lib/fpending.c (__fpending):
* lib/fpurge.c (fpurge):
* lib/freadable.c (freadable):
* lib/freadahead.c (freadahead):
* lib/freading.c (freading):
* lib/freadptr.c (freadptr):
* lib/freadseek.c (freadptrinc):
* lib/fseeko.c (fseeko):
* lib/fseterr.c (fseterr):
* lib/fwritable.c (fwritable):
* lib/fwriting.c (fwriting):
Check _IO_EOF_SEEN instead of _IO_ftrylockfile.
* lib/stdio-impl.h (_IO_IN_BACKUP) [_IO_EOF_SEEN]:
Define if not already defined.
---
 lib/fflush.c     | 6 +++---
 lib/fpurge.c     | 2 +-
 lib/freading.c   | 2 +-
 lib/fseeko.c     | 4 ++--
 lib/stdio-impl.h | 6 ++++++
 5 files changed, 13 insertions(+), 7 deletions(-)
 
diff --git a/lib/fflush.c b/lib/fflush.c
index 983ade0ff..a6edfa105 100644
--- a/lib/fflush.c
+++ b/lib/fflush.c
@@ -33,7 +33,7 @@
 #undef fflush
 
 
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
 
 /* Clear the stream's ungetc buffer, preserving the value of ftello (fp).  */
 static void
@@ -72,7 +72,7 @@ clear_ungetc_buffer (FILE *fp)
 
 #endif
 
-#if ! (defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */)
+#if ! (defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */)
 
 # if (defined __sferror || defined __DragonFly__ || defined __ANDROID__) && defined __SNPT
 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
@@ -148,7 +148,7 @@ rpl_fflush (FILE *stream)
   if (stream == NULL || ! freading (stream))
     return fflush (stream);
 
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
 
   clear_ungetc_buffer_preserving_position (stream);
 
diff --git a/lib/fpurge.c b/lib/fpurge.c
index b1d417c7a..3aedcc373 100644
--- a/lib/fpurge.c
+++ b/lib/fpurge.c
@@ -62,7 +62,7 @@ fpurge (FILE *fp)
   /* Most systems provide FILE as a struct and the necessary bitmask in
      <stdio.h>, because they need it for implementing getc() and putc() as
      fast macros.  */
-# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+# if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
   fp->_IO_read_end = fp->_IO_read_ptr;
   fp->_IO_write_ptr = fp->_IO_write_base;
   /* Avoid memory leak when there is an active ungetc buffer.  */
diff --git a/lib/freading.c b/lib/freading.c
index 73c28acdd..c24d0c88a 100644
--- a/lib/freading.c
+++ b/lib/freading.c
@@ -31,7 +31,7 @@ freading (FILE *fp)
   /* Most systems provide FILE as a struct and the necessary bitmask in
      <stdio.h>, because they need it for implementing getc() and putc() as
      fast macros.  */
-# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+# if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
   return ((fp->_flags & _IO_NO_WRITES) != 0
           || ((fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0
               && fp->_IO_read_base != NULL));
diff --git a/lib/fseeko.c b/lib/fseeko.c
index 0101ab55f..193f4e8ce 100644
--- a/lib/fseeko.c
+++ b/lib/fseeko.c
@@ -47,7 +47,7 @@ fseeko (FILE *fp, off_t offset, int whence)
 #endif
 
   /* These tests are based on fpurge.c.  */
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
   if (fp->_IO_read_end == fp->_IO_read_ptr
       && fp->_IO_write_ptr == fp->_IO_write_base
       && fp->_IO_save_base == NULL)
@@ -123,7 +123,7 @@ fseeko (FILE *fp, off_t offset, int whence)
           return -1;
         }
 
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
       fp->_flags &= ~_IO_EOF_SEEN;
       fp->_offset = pos;
 #elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
diff --git a/lib/stdio-impl.h b/lib/stdio-impl.h
index 78d896e9f..05c5752a2 100644
--- a/lib/stdio-impl.h
+++ b/lib/stdio-impl.h
@@ -18,6 +18,12 @@
    the same implementation of stdio extension API, except that some fields
    have different naming conventions, or their access requires some casts.  */
 
+/* Glibc 2.28 made _IO_IN_BACKUP private.  For now, work around this
+   problem by defining it ourselves.  FIXME: Do not rely on glibc
+   internals.  */
+#if !defined _IO_IN_BACKUP && defined _IO_EOF_SEEN
+# define _IO_IN_BACKUP 0x100
+#endif
 
 /* BSD stdio derived implementations.  */
 
-- 
2.17.1

备注: 改完文件以后不能直接make,因为还得修改Makefile

2. 解决fseterr.c报错

/Hi3516EV200_SDK_V5.0.1.1/osdrv/tools/pc/hi_gzip/路径下,新建一个patch文件(补丁文件),比如:lll.patch(后缀是.patch即可)
lll.patch文件中填入以下内容,然后保存退出,这样补丁文件就有了。

(rdslw@black) (beewrt-18.06) /flower/openwrt.git :) cat tools/bison/patches/110-glibc-change-work-around.patch                                                                                         
  2 Subject: Workaround change in glibc
  3 
  4 Temporary workaround to compile with glibc 2.28, which
  5 deprecated some constants
  6 
  7 Based on the workaround made for the tools/m4 package
  8 
  9 +/* Glibc 2.28 made _IO_IN_BACKUP private.  For now, work around this
 10 +   problem by defining it ourselves.  FIXME: Do not rely on glibc
 11 +   internals.  */
 12 +#if !defined _IO_IN_BACKUP && defined _IO_EOF_SEEN
 13 +# define _IO_IN_BACKUP 0x100
 14 +#endif
 15 
 16  /* BSD stdio derived implementations.  */
 17 
 18 --- a/lib/fseterr.c
 19 +++ b/lib/fseterr.c
 20 @@ -29,7 +29,7 @@
 21    /* Most systems provide FILE as a struct and the necessary bitmask in
 22       <stdio.h>, because they need it for implementing getc() and putc() as
 23       fast macros.  */
 24 -#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
 25 +#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
 26    fp->_flags |= _IO_ERR_SEEN;
 27  #elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */
 28    fp_->_flags |= __SERR;

备注: 改完文件以后不能直接make,因为还得修改Makefile

3.修改Makefile

进入目录下的Makefile,进行修改

  1 CC = gcc
  2 RM = -rm -rf
  3 
  4 SRCS = $(wildcard src/*.c)
  5 EXENAME = hi_gzip
  6 
  7 all: gzip hi_gzip
  8 
  9 gzip:
 10     tar -xf gzip-1.8.tar.gz
 11     cd gzip-1.8
 12     pushd gzip-1.8;patch -p1 < ../hi_gzip.patch;./configure;make -j12;popd                                                                            
 14 hi_gzip: $(OBJS)
 15     mkdir bin -p
 16     cp gzip-1.8/gzip bin;
 17     @$(CC) $(SRCS) -o bin/$(EXENAME)
 18 
 19 clean:
 20     @$(RM) -rf *.bak *~ bin
 21     @$(RM) -rf gzip-1.8
 22 
 23 .PHONY: all clean

以上是我原始的Makefile,注意看12行:patch -p1 < ../hi_gzip.patch;的作用是执行指定的补丁文件,我们在这里添加新建的两个补丁文件即可,所以可以把12行改成:

pushd gzip-1.8;patch -p1 < ../hi_gzip.patch;patch -p1 < ../ll.patch;patch -p1 < ../lll.patch;./configure;make -j12;popd 

问题解决!

参考博文:
  • 7
    点赞
  • 38
    收藏
    觉得还不错? 一键收藏
  • 8
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值