#133 compile with libpng15 fails

open
nobody
None
5
2012-04-05
2012-04-05
rosc2112
No

g++ -O6 -pthread -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include
slackware linux system, tried both v.1.1.1 and cvs, and come across this error when compiling, using libpng15 (just recently upgraded, and the new libpng is wreaking havok all over my system lol)

g++ -O6 -pthread -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng15 -c cimg.cc -o cimg.o

cimg.cc: In constructor 'CImg::CImg(const char*)':

cimg.cc:97:13: error: invalid use of incomplete type 'struct png_struct'

/usr/include/libpng15/png.h:847:16: error: forward declaration of 'struct png_struct'

cimg.cc:97:25: error: invalid use of incomplete type 'struct png_struct'

/usr/include/libpng15/png.h:847:16: error: forward declaration of 'struct png_struct'

cimg.cc:101:17: error: invalid use of incomplete type 'struct png_struct'

/usr/include/libpng15/png.h:847:16: error: forward declaration of 'struct png_struct'

make: *** [cimg.o] Error 1

How can I fix this?

Thanks in advance.

Discussion

  • rosc2112
    rosc2112
    2012-04-05

    oops my cut/paste got a little mangled up there, the very 1st line with my text shouldn't have included that g++ pastie.

     
  • Here's a patch, tested with 1.0.4:
    --- cimg.cc.orig 2007-05-23 18:57:45.000000000 +0000
    +++ cimg.cc
    @@ -95,16 +95,16 @@ CImg::CImg(const char *filename) {
    ct == PNG_COLOR_TYPE_GRAY_ALPHA)
    png_set_gray_to_rgb(pngp);

    - alloc(pngp->width,pngp->height);
    + alloc(png_get_image_width(pngp, infp),png_get_image_height(pngp, infp));
    if (!ok) { fclose(f); return; }
    ok = 0;

    - rp = (png_bytep *) malloc(sizeof(png_bytep) * (pngp->height));
    + rp = (png_bytep *) malloc(sizeof(png_bytep) * (png_get_image_height(pngp, infp)));
    if (rp==NULL) {
    fclose(f); return;
    }

    - for(i=0;i<pngp->height;i++) {
    + for(i=0;i<png_get_image_height(pngp, infp);i++) {
    png_read_row(pngp, (png_bytep) (&data[i*rowlen]), NULL);
    }