libpng “png_set_longjmp_fn” not found

前端 未结 3 823
深忆病人
深忆病人 2021-01-18 04:47

I\'m using libpng from ubuntu and when I try to compile a c++ file I get

undefined reference to `png_set_longjmp_fn\'

I\'m using libpng version 1.6.8

相关标签:
3条回答
  • 2021-01-18 05:22

    In my case, I have the old png 1.2 came with my ubuntu installed in /usr. I installed the 1.6.x in /usr/local. In my make system, the default include /usr/include and linking /usr/lib were picked up. When compiling any software that rely on the new interface, you need to add

    CPPFLAGS="-I/usr/local/include $CPPFLAGS"
    LDFLAGS="-L/usr/local/lib $LDFLAGS"
    

    this will pick up

    grep png_set_longjmp_fn png.h
    PNG_EXPORT(8, jmp_buf*, png_set_longjmp_fn, (png_structrp png_ptr,
          (*png_set_longjmp_fn((png_ptr), longjmp, (sizeof (jmp_buf))))
    

    from the newer interface

    0 讨论(0)
  • 2021-01-18 05:29

    Perhaps you have built with libpng-1.6.8 but are linking to an earlier version of libpng. The "png_set_longjmp_fn()" API was introduced in libpng-1.4.x. Ubuntu 13:10 currently comes with libpng-1.2.49 (see /usr/include/libpng12), which does not supply png_set_longjmp_fn().

    0 讨论(0)
  • 2021-01-18 05:44

    If you do this on an older Playstation Portable program you also might have stale libraries in the source directory. Run rm *.a then make clean which happened to fix that error message for me.

    0 讨论(0)
提交回复
热议问题