SOLVED(?): failed to load "./stock_about_16.png": Couldn't recognize the image file format

There have been numerous reports of the following error:

failed to load "./stock_about_16.png": Couldn't recognize the image file
for file './stock_about_16.png'

from people compiling gtk+ on various platforms (see bugzilla 108718 and
102142).  I got the error on Solaris9, and a little digging revealed
that my .loaders file listed all of the loaders except png.  Running
'make gdk-pixbuf.loaders' manually showed a missing symbol/relocation
error when trying to load

Short version: LIBPNG was '-L/path/to/lib -lpng12' but needed to be
'-L/path/to/lib -lpng12 -lz' because my libpng was shared, and linked
against a shared zlib.  Unless -lz is explicitly linked as a dependency
when compiling, when is
dlopened that zlib dependency is dropped, and is not loaded --
so gdk-pixbuf-query-loaders gets that missing symbol error for  Only the direct dependencies of are loaded with it, and not the third-level ones.

However, building with an explicit link
dependency on -lz should NOT be necessary:
doesn't use zlib directly.  And, "deep linking" like this is bad:

which is why the png folks have had a long policy against including -lz
in their pkg-config --libs output (.pc file).  However, it seems that on
some platforms (Solaris, HP?, to judge by the error reports) the runtime
loader works differently when implicitly loading a shared library at
application startup, than when loading it via dlopen().  In the former
case, the lower-level dependency gets loaded even tho the app did not
link directly against it.  In the latter case...see above.

I don't have a universal non-ugly solution to the general problem -- but
I wanted to at least record this workaround for the next person who ran
into this error with gtk+:

Manually add -lz to LIBPNG in the gdk-pixbuf/Makefile.

  Charles Wilson
  cygwin at removespam cwilson dot fastmail dot fm

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]