一、遇到的问题:
编译Hi518EV300 LiteOS 时遇到如下问题:
lib/fseterr.c: In function 'fseterr':
lib/fseterr.c:77:3: error:
lib/fseeko.c: In function 'fseeko':
lib/fseeko.c:77:3: error:
二、网上的这种解决方法不能解决以上问题
进入文件对应的目录,执行下面的语句:
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 @@
-
+
/* Clear the stream's ungetc buffer, preserving the value of ftello (fp). */
static void
@@ -72,7 +72,7 @@ clear_ungetc_buffer (FILE *fp)
-
+
/* 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);
-
+
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. */
-
+
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. */
-
+
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)
/* These tests are based on fpurge.c. */
-
+
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;
}
-
+
fp->_flags &= ~_IO_EOF_SEEN;
fp->_offset = pos;
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. */
+
+
+
/* 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 +
13 +
14 +
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 -
25 +
26 fp->_flags |= _IO_ERR_SEEN;
27
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
问题解决!
参考博文:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)