xinggangw / leptonica

Automatically exported from code.google.com/p/leptonica
1 stars 0 forks source link

gilfib 5.0.0 compatibility #63

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. install giflib 5.0.0
2. try to compile leptonica

What is the expected output? What do you see instead?
Expected successful compile but got:

libtool: compile:  /usr/bin/gcc-4.2 -DHAVE_CONFIG_H -I. -I.. 
-I/i386-10.6-mp/include -pipe -O2 -arch i386 -MT gifio.lo -MD -MP -MF 
.deps/gifio.Tpo -c gifio.c  -fno-common -DPIC -o .libs/gifio.o
gifio.c: In function ‘pixReadStreamGif’:
gifio.c:92: error: too few arguments to function ‘DGifOpenFileHandle’
gifio.c: In function ‘pixWriteStreamGif’:
gifio.c:308: warning: assignment makes pointer from integer without a cast
gifio.c:329: error: too few arguments to function ‘EGifOpenFileHandle’
make[2]: *** [gifio.lo] Error 1

What version of the product are you using? On what operating system?
leptonica 1.68, OS X 10.6.8, Xcode 3.2.6

Please provide any additional information below.
giflib 5.0.0 changed / removed / renamed several functions; see giflib 
documentation.

Original issue reported on code.google.com by ryandesi...@gmail.com on 27 Jun 2012 at 9:55

GoogleCodeExporter commented 8 years ago
It does appear that they broke the low-level interface with 5.0.0.
This is messy to deal with, because 4.1.6 is going to be out there
for many years to come.  Unfortunate.

For the forseeable future, suggest you use 4.1.6.
Or, unless you really need gif for some reason, use png,
which is superior in all respects.

Original comment by dan.bloo...@gmail.com on 27 Jun 2012 at 3:45

GoogleCodeExporter commented 8 years ago
I am a manager of the MacPorts package management system, and the maintainer of 
our giflib port, which is currently at version 4.2.0. Because I wish to update 
giflib to version 5.0.0 (as I wish to update all ports to their current 
versions), I'm testing our giflib-using software with giflib 5, and reporting 
bugs as needed. Please add giflib 5 compatibility to leptonica so that it will 
eventually be possible for MacPorts and other package management systems to 
update to giflib 5. I am not a developer of compiled software so I don't know 
how difficult this is to do. If you find it difficult, you might want to 
express that concern to the developer of giflib so he knows what problems he's 
causing his users.

Original comment by ryandesi...@gmail.com on 14 Jul 2012 at 10:07

GoogleCodeExporter commented 8 years ago
The same problem in openSUSE.

Original comment by lazy.ken...@gmail.com on 8 Jan 2013 at 7:24

GoogleCodeExporter commented 8 years ago
After thinking about this for a while, I have decided not to upgrade the code 
at this time, or force any user of leptonica into upgrading to gif 5.0.

Eric Raymond did a very bad thing on June 20, 2012.  He made a new version that 
is incompatible with 4.x, so that users would have to get the new version, and 
libraries like leptonica would have to support one or the other, a very unhappy 
situation.  For a library like giflib, that is used directly and indirectly in 
thousands of applications, to break the existing interface is inexcusable.

This may sort out in a year or three.  Perhaps Eric will reconsider and put the 
old interfaces back in (he can mark them "obsolete" if he wants).  If he does 
not, and in the future I determine that a significant number of users of 
leptonica have giflib 5.0 and that it's worth breaking the packages of people 
who are using 4.x, I may reconsider.  But don't count on it.

Upgrading a crummy 18-year old legacy library can be seen as a worthwhile 
project.  Pulling a stunt like this, however, should be a nail in its coffin.  
In any event, gif has been obsolete for over 10 years, since the adoption of 
png in browsers and packages, regardless of the patent situation for the 
particular version of liv-zempel compression that gif uses.

This is in the README from the giflib 5.0.3 download from Source Forge:

    GIF is a legacy format; we recommend against generating new images in
    it.  For a cleaner, more extensible design with better color support
    and compression, look up PNG.

To maintainers of packages that use leptonica, if you want to use giflib 5.0, 
don't link it with leptonica.  You can change the line in the leptonica 
configure.ac that looks for DGifOpenFileHandle to look instead for 
DGifOpenFileHandleNotFound, before running configure.

Original comment by dan.bloo...@gmail.com on 8 Jan 2013 at 11:02

GoogleCodeExporter commented 8 years ago
OK, I've changed my mind.  It is not fair to punish users for bad library 
maintenance in a dependent library.

Rants aside, all versions of giflib will be supported in 1.70.  I'll change the 
line in configure.ac to identify all versions.

Original comment by dan.bloo...@gmail.com on 31 Jan 2013 at 5:59

GoogleCodeExporter commented 8 years ago
In fact, configure.ac is fine as is.  We just need tests for GIFLIB_MAJOR in 
gifio.c.

Original comment by dan.bloo...@gmail.com on 31 Jan 2013 at 6:04

GoogleCodeExporter commented 8 years ago
Thanks.
I see a similar solution in openSUSE WindowMaker.
wm-giflib.patch, at the end of the file (skip ~2380 lines).
https://build.opensuse.org/package/view_file?expand=1&file=wm-giflib.patch&packa
ge=WindowMaker&project=X11%3Awindowmanagers

Original comment by lazy.ken...@gmail.com on 31 Jan 2013 at 6:57

GoogleCodeExporter commented 8 years ago
Temporary patch from openSUSE maintainer Stefan Seyfried.

diff --git a/src/gifio.c b/src/gifio.c
index f653ae2..e086380 100644
--- a/src/gifio.c
+++ b/src/gifio.c
@@ -100,7 +100,11 @@ SavedImage       si;
     _lseek(fd, 0, SEEK_SET);
 #endif  /* _MSC_VER */

+#if GIFLIB_MAJOR < 5
     if ((gif = DGifOpenFileHandle(fd)) == NULL)
+#else
+    if ((gif = DGifOpenFileHandle(fd, NULL)) == NULL)
+#endif
         return (PIX *)ERROR_PTR("invalid file or file not found",
                                 procName, NULL);

@@ -316,6 +320,10 @@ GifByteType     *gif_line;
     }

         /* Save the cmap colors in a gif_cmap */
+#if GIFLIB_MAJOR >= 5
+#define MakeMapObject GifMakeMapObject
+#define FreeMapObject GifFreeMapObject
+#endif
     if ((gif_cmap = MakeMapObject(gif_ncolor, NULL)) == NULL) {
         pixDestroy(&pixd);
         return ERROR_INT("failed to create GIF color map", procName, 1);
@@ -337,7 +345,11 @@ GifByteType     *gif_line;
     }

         /* Get the gif file handle */
+#if GIFLIB_MAJOR < 5
     if ((gif = EGifOpenFileHandle(fd)) == NULL) {
+#else
+    if ((gif = EGifOpenFileHandle(fd, NULL)) == NULL) {
+#endif
         pixDestroy(&pixd);
         FreeMapObject(gif_cmap);
         return ERROR_INT("failed to create GIF image handle", procName, 1);

Original comment by lazy.ken...@gmail.com on 20 Mar 2013 at 6:07

GoogleCodeExporter commented 8 years ago
Fixed in 1.70, which you can get at leptonica.org/download.html

This now works with either 4.1.X or 5.0.X

Original comment by dan.bloo...@gmail.com on 23 Jan 2014 at 8:43