[gdal-dev] LibPNG compatibility issue

Even Rouault even.rouault at mines-paris.org
Mon Aug 19 03:35:14 PDT 2013


Selon Olivier BARTHELEMY <barthelemy at geovariances.com>:

> I'm having a strange error when Gdal uses libpng
>
> Environment :
> x86-64 linux
> gdal 1.10
> libpng 1.6.2
>
> I am getting the following message :
>
> GDAL (CPLE_NotSupported): The PNG driver failed to in
> png_create_read_struct().
> This may be due to version compatibility problems.
>
> which is in this snippet in pngdataset.cpp:
>
> #if LIBPNG_VER_MINOR >= 2 || LIBPNG_VER_MAJOR > 1
>         int version = png_access_version_number();
>         CPLError( CE_Failure, CPLE_NotSupported,
>                   "The PNG driver failed to access libpng with version
> '%s',"
>                   " library is actually version '%d'.\n",
>                   PNG_LIBPNG_VER_STRING, version);
> #else
>         CPLError( CE_Failure, CPLE_NotSupported,
>                   "The PNG driver failed to in png_create_read_struct().\n"
>                   "This may be due to version compatibility problems." );
> #endif
>
> If i understand correctly, if i get the second messsage, that is supposed
> to mean that pngdataset.cpp was compiled with a libpng older than 1.2, or
> that the macros don't exist (#if takes a value of 0 if a macro name is not
> found)
>
> I compiled my GDAl with libpng 1.6.2, and ldd properly tells me that it's
> this version GDAL tries to link to
>
> I think i don't get the first message because, at least for png 1.5 and 1.6
> ( and even the v1.2 shipped with gdal ), LIBPNG_VER_MINOR  and
> LIBPNG_VER_MAJOR are not in png.h. Instead, there are PNG_LIBPNG_VER_MINOR
>  and PNG_LIBPNG_VER_MAJOR. So the code should also try to look for those
> macros

Yes, there's an issue in this code (could you file a ticket in GDAL Trac about
that ?). But the consequence is only on the error message, not on the error that
caused this code path to be reached.

My assumption is that you've built a first time pngdataset.cpp against the GDAL
internal libpng (1.2), and then configured later with your external libpng 1.6
but pngdataset.cpp didn't get recompiled. So at runtime there's a mismatch.

Try cleaning (or just "touch frmts/png/pngdataset.cpp") before rebuilding GDAL.

>
> As to why i am reaching this code, i couldn't find if GDAL is compatible
> with libPNG 1.6, could you confirm it? I successfully build with it on
> windows and linux; it works on widowns (and might have previously worked on
> linux, before i recompiled gdal to add the python module)
>
> --
> Olivier BARTHELEMY
>




More information about the gdal-dev mailing list