[GRASS-dev] [GRASS GIS] #1347: r.out.png uses now hidden libpng structs

#1347: r.out.png uses now hidden libpng structs
-------------------------+--------------------------------------------------
Reporter: kyngchaos | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 6.4.2
Component: Raster | Version: 6.4.0
Keywords: png | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------
Just my luck - I upgrade to libpng 1.5 ''after'' the GRASS 6.4.1 release.

libpng 1.5 does not include the png_info struct (and others) in the png.h
header, it's now in a private pnginfo.h. r.out.png needs this. I didn't
see any option in libpng compilation to install these new headers.

Compilation fails with

{{{
r.out.png.c: In function ‘main’:
r.out.png.c:264: error: dereferencing pointer to incomplete type
r.out.png.c:265: error: dereferencing pointer to incomplete type
r.out.png.c:266: error: dereferencing pointer to incomplete type
r.out.png.c:306: error: dereferencing pointer to incomplete type
r.out.png.c:308: error: dereferencing pointer to incomplete type
}}}

Note also that png.h does not include zlib.h now (as the #include png.h in
pngfunc.h currently says). I didn't get an error about this in r.out.png
(yet), but I have had an error in other projects.

The png driver didn't have any errors.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1347&gt;
GRASS GIS <http://grass.osgeo.org>

#1347: r.out.png uses now hidden libpng structs
-------------------------+--------------------------------------------------
Reporter: kyngchaos | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 6.4.2
Component: Raster | Version: 6.4.0
Keywords: png | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(by hamish):

Replying to [ticket:1347 kyngchaos]:
> Just my luck - I upgrade to libpng 1.5

apparently 1.5.0 was buggy, make sure you have 1.5.1+.

> libpng 1.5 does not include the png_info struct (and others)
> in the png.h header, it's now in a private pnginfo.h. r.out.png
> needs this. I didn't see any option in libpng compilation to
> install these new headers.

http://www.libpng.org/pub/png/src/libpng-1.2.x-to-1.4.x-summary.txt

{{{
2. Some obsolete/deprecated macros and functions have been removed.
...
    f. We removed the functions png_read_init(info_ptr),
       png_write_init(info_ptr), png_info_init(info_ptr),
       png_read_destroy(), and png_write_destroy().
       They have been deprecated since libpng-0.95.
}}}

Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1347#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#1347: r.out.png uses now hidden libpng structs
-------------------------+--------------------------------------------------
Reporter: kyngchaos | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 6.4.2
Component: Raster | Version: 6.4.0
Keywords: png | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(by hamish):

oops, the fns in the last msg were already taken care of in grass source.

as for moving png_info from png.h to pnginfo.h, see changelog starting
http://libpng.git.sourceforge.net/git/gitweb.cgi?p=libpng/libpng;a=blob;f=CHANGES;h=fb069121a45024e4904e7f4ea0636f183b7ec350;hb=refs/tags/v1.5.2#l2663

I guess we need to set up some #ifdefs based on
`PNG_LIBPNG_VER_MAJOR == 1` and `PNG_LIBPNG_VER_MINOR >= 5`

but I'm not sure how the libpng15 version should look yet.

Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1347#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>

#1347: r.out.png uses now hidden libpng structs
-------------------------+--------------------------------------------------
Reporter: kyngchaos | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 6.4.2
Component: Raster | Version: 6.4.0
Keywords: png | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(by kyngchaos):

I was generalizing the version to imply it was a major version upgrade,
1.5.x. But yes, I do have 1.5.2.

Maybe for a quick fix I could #include that pnginfo.h from my libpng
source just to get r.out.png compiled?

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1347#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>

#1347: r.out.png uses now hidden libpng structs
-------------------------+--------------------------------------------------
Reporter: kyngchaos | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 6.4.2
Component: Raster | Version: 6.4.0
Keywords: png | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(by glynn):

Replying to [comment:2 hamish]:

> I guess we need to set up some #ifdefs based on
> `PNG_LIBPNG_VER_MAJOR == 1` and `PNG_LIBPNG_VER_MINOR >= 5`

I think that we should just switch to using the new API. I doubt that
anyone is still using libpng 0.9x.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1347#comment:4&gt;
GRASS GIS <http://grass.osgeo.org>

#1347: r.out.png uses now hidden libpng structs
-------------------------+--------------------------------------------------
Reporter: kyngchaos | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 6.4.2
Component: Raster | Version: 6.4.0
Keywords: png | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(by hamish):

Replying to [comment:4 glynn]:
> I think that we should just switch to using the new API.
> I doubt that anyone is still using libpng 0.9x.

actually all the 0.9x stuff is already "#ifdef OLDPNG"'d out.

the trouble in this bug is libpng taking formerly public header files and
making them private in various stages between versions 1.3 and 1.5.
(afaiu)

Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1347#comment:5&gt;
GRASS GIS <http://grass.osgeo.org>

#1347: r.out.png uses now hidden libpng structs
-------------------------+--------------------------------------------------
Reporter: kyngchaos | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 6.4.2
Component: Raster | Version: 6.4.0
Keywords: png | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(by glynn):

Replying to [comment:5 hamish]:

> the trouble in this bug is libpng taking formerly public header files
and making them private in various stages between versions 1.3 and 1.5.
(afaiu)

The only header we use is <png.h>. The issue is that the structure
definitions have finally been removed from png.h, so applications need to
use the appropriate functions rather than manipulating structure fields
directly or allocating the structures as local variables.

There shouldn't be any need for conditional compilation (#ifdef). The new
(non-deprecated) API has been around long enough that we can take it for
granted.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1347#comment:6&gt;
GRASS GIS <http://grass.osgeo.org>

#1347: r.out.png uses now hidden libpng structs
-------------------------+--------------------------------------------------
Reporter: kyngchaos | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 6.4.2
Component: Raster | Version: 6.4.1
Keywords: png | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------
Changes (by volter):

  * version: 6.4.0 => 6.4.1

Comment:

I just ran into this issue, trying to build 6.4.1 for Fedora rawhide, that
also has libpng 1.5. Is there a quick fix I could use?

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1347#comment:7&gt;
GRASS GIS <http://grass.osgeo.org>

#1347: r.out.png uses now hidden libpng structs
-------------------------+--------------------------------------------------
Reporter: kyngchaos | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 6.4.2
Component: Raster | Version: 6.4.1
Keywords: png | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(by glynn):

Replying to [comment:7 volter]:
> I just ran into this issue, trying to build 6.4.1 for Fedora rawhide,
that also has libpng 1.5. Is there a quick fix I could use?
Try back-porting r43927.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1347#comment:8&gt;
GRASS GIS <http://grass.osgeo.org>

#1347: r.out.png uses now hidden libpng structs
-------------------------+--------------------------------------------------
Reporter: kyngchaos | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 6.4.2
Component: Raster | Version: 6.4.1
Keywords: png | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(by volter):

Brilliant, seems to work. Thank you!

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1347#comment:9&gt;
GRASS GIS <http://grass.osgeo.org>

#1347: r.out.png uses now hidden libpng structs
--------------------------+-------------------------------------------------
  Reporter: kyngchaos | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: major | Milestone: 6.4.2
Component: Raster | Version: 6.4.1
Resolution: fixed | Keywords: png
  Platform: Unspecified | Cpu: Unspecified
--------------------------+-------------------------------------------------
Changes (by neteler):

  * status: new => closed
  * resolution: => fixed

Comment:

Backported in r49345 and r49346. Closing.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1347#comment:10&gt;
GRASS GIS <http://grass.osgeo.org>