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

2023-05-16

一、遇到的问题:

编译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 

问题解决!

参考博文:

  • https://forum.openwrt.org/t/tools-bison-lib-fseterr-c-build-problems-on-18-06-0-due-to-glibc-2-28-changes/18926

  • https://src.fedoraproject.org/rpms/gcal/blob/master/f/gcal-glibc-no-libio.patch

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

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

  • iOS SDK:如何检查端口是否打开?

    我还没有找到任何关于如何检查端口是否打开的信息 我尝试使用 AsyncSocket 类来实现它 但它始终返回 TRUE 尽管我拒绝与服务器上该端口的所有连接 此外 我尝试使用isConnectedAsyncSocket 的方法 但总是返回
  • CouchDB IP 地址和端口

    当我启动 couchDB 时 它正在运行http 127 0 0 1 5984 我有另一个程序需要在同一端口上运行 所以我想将 couchDB 更改为其他程序 有任何想法吗 在您的中指定端口local ini config httpd po
  • 在同一端口上接收多个多播源 - C、Linux

    我有一个应用程序正在同一端口上从多个多播源接收数据 我能够接收数据 然而 我试图解释每组的统计数据 即收到的消息 收到的字节 并且所有数据都变得混乱 有谁知道如何解决这个问题 如果我尝试查看发送者的地址 它不是多播地址 而是发送机器的 IP
  • Amazon Redshift 中的递归 CTE

    我们正在尝试移植代码以在 Amazon Redshift 上运行 但 Refshift 不会运行递归 CTE 函数 有好心人知道如何移植这个吗 with tt as select t row number over partition by
  • 端口和套接字之间的混淆

    好吧 当我尝试研究 IP 地址 端口和套接字时 我得到了以下结果 IP 地址用于映射到网络上的不同设备 端口号用于访问主机上的特定应用程序 套接字是两者的组合 我不明白的是 如果端口将您连接到特定应用程序 那么每个应用程序应该只有 1 个端
  • 有没有办法在 Kubernetes 中保留传出流量的源端口?

    在大多数 TCP 客户端 服务器通信中 客户端使用随机通用端口号进行传出流量 但是 我的客户端应用程序在 Kubernetes 集群内运行 必须使用特定的端口号进行传出流量 这是由于服务器的要求 当应用程序在外部运行时 这通常工作正常 但在
  • 如何在 Docker 第 3 部分教程中使用curl -4 http://localhost?

    使用 Docker 教程我被困在这部分 https docs docker com get started part3 run your new load balanced app https docs docker com get sta
  • 我如何知道 docker 容器的主机映射端口?

    我有一个正在运行的 docker 容器 其中我已将主机的 8090 端口映射到 docker 容器的 8080 端口 运行 tomcat 服务器 有什么方法可以从容器中获取映射的端口信息吗 即有什么方法可以让我了解容器中的 8090 808
  • Docker - Node.js + MongoDB - “错误:无法连接到 [localhost:27017]”

    我正在尝试为我的容器创建一个容器Node应用程序 这个应用程序使用MongoDB以确保一些数据的持久性 所以我创建了这个Dockerfile FROM ubuntu latest Installing MongoDB Add 10gen o
  • 如何配置一个网络中的容器相互连接(服务器 -> mysql)?

    我已经在 Windows 上运行了 ubuntu docker containers mysql 和 nodejs server app docker run d 网桥 name own p 80 3000 own latest docke
  • Docker:我无法将 80 以外的端口映射到我的 WordPress 容器

    我想在我的计算机上映射一些随机端口 例如localhost 7006到我的 WordPress docker 容器port 80 当我更改 WordPress 的端口时80 80 to 7006 80它不仅停止工作localhost por
  • PHP COM口与DIO的连接

    我正在尝试用 PHP 连接称重机 我已经用超级终端测试过它工作正常 但是当我使用 PHP 代码时fopen or dio open它被执行但是当fgets or dio read被调用时 它挂起并且不显示任何内容 Fopen 示例 exec
  • Maven - java.net.BindException:地址已在使用中

    我正在尝试在 Ubuntu 12 04 中运行以下命令 mvn jetty run 并收到以下错误 2013 09 04 13 21 32 843 WARN failed email protected cdn cgi l email pr
  • 如何停止 adb 端口转发?

    可以转发端口adb forward tcp 8080 tcp 8080 但是我需要终止 adb 服务器来停止此转发吗 我正在寻找一种方法来停止 adb 中端口的转发 在设置之后 但不再需要转发时 Try adb forward remove
  • Apache httpd 与 Tomcat 7:端口 80 与端口 8080

    我最近在 Amazon ec2 上安装了 Tomcat 7 我发现Tomcat默认监听8080端口 互联网上的文档主张这是因为linux更好地将较低的端口保存给超级用户 顺便说一句 ec2 上的解决方案是创建一个负载均衡器 将通信从端口 8
  • 如何在 Google Compute Engine 中打开特定端口(例如 9090)

    我有 2 个 Google Compute Engine 实例 我想在这两个实例中打开端口 9090 我认为我们需要添加一些防火墙规则 你能告诉我该怎么做吗 Answer recommended by Google Cloud collec
  • 用于查看特定端口的命令行

    有没有办法从 Windows 命令行检查特定端口的状态 我知道我可以使用 netstat 检查所有端口 但 netstat 很慢 并且查看特定端口可能不会 这里是简单的解决方案端口查找 In cmd netstat na find 8080
  • 如何将 Cocoa/Mac 应用程序移植到 Windows?

    如何将 Cocoa Mac 应用程序移植到 Windows 我的意思是你会怎么做 假设应用程序是用 Objective C 和 Cocoa 编写的 没有什么花哨的事情发生 没有可以分解的 引擎 等等 从头开始重写 我不认为 Mac 和 Wi
  • 我可以使用单个 websocket 服务器同时打开 2 个端口吗

    我是 websocket 编程的新手 目前我正在开发一个简单的 websocket 服务器 使用 c 可以响应 websocket 客户端 我设法在单个端口上使用 1 个客户端和 1 个服务器 我想知道是否可以打开 2 个端口 以便不同的客
  • 由于权限被拒绝,无法绑定到某些端口

    在过去 3 个月左右的时间里 我遇到了随机错误 无法绑定身份服务器在本地开发工作站上运行的特定端口 起初我以为是我的机器坏了 所以我重置了所有东西 这在两个月内解决了这个问题 现在它又回来了 与此同时 其他开发人员也看到了同样的问题 我们所

随机推荐