尝试安装PyQt5失败

卡在:编译 qtbase/src/gui/image/qpnghandler.cpp时报错:

.obj/qpnghandler.o: In function `QPngHandlerPrivate::readPngHeader()':
qpnghandler.cpp:(.text+0xbe2): undefined reference to `png_set_longjmp_fn'
.obj/qpnghandler.o: In function `QPNGImageWriter::writeImage(QImage const&, int, QString const&, int, int)':
qpnghandler.cpp:(.text+0x273b): undefined reference to `png_set_longjmp_fn'
.obj/qpnghandler.o: In function `QPngHandlerPrivate::readPngImage(QImage*)':
qpnghandler.cpp:(.text+0x30cc): undefined reference to `png_set_longjmp_fn'
collect2: ld returned 1 exit status

我以为是没有加-lpng库,在Makefile中添加了 -lpng,结果还是没能解决。

打开qtbase/src/gui/image/qpnghandler.cpp文件:


#if PNG_LIBPNG_VER >= 10400 && PNG_LIBPNG_VER <= 10502 \
        && defined(PNG_PEDANTIC_WARNINGS_SUPPORTED)
/*
    Versions 1.4.0 to 1.5.2 of libpng declare png_longjmp_ptr to
    have a noreturn attribute if PNG_PEDANTIC_WARNINGS_SUPPORTED
    is enabled, but most declarations of longjmp in the wild do
    not add this attribute. This causes problems when the png_jmpbuf
    macro expands to calling png_set_longjmp_fn with a mismatched
    longjmp, as compilers such as Clang will treat this as an error.
 
    To work around this we override the png_jmpbuf macro to cast
    longjmp to a png_longjmp_ptr.
*/
#   undef png_jmpbuf
#   ifdef PNG_SETJMP_SUPPORTED
#       define png_jmpbuf(png_ptr) \
            (*png_set_longjmp_fn((png_ptr), (png_longjmp_ptr)longjmp, sizeof(jmp_buf)))
#   else
#       define png_jmpbuf(png_ptr) \
            (LIBPNG_WAS_COMPILED_WITH__PNG_NO_SETJMP)
#   endif
#endif

这该怎么处理呀?

如下为调用到 png_jmpbuf 的地方:


    if (setjmp(png_jmpbuf(png_ptr))) {
        png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
        png_ptr = 0;
        amp.deallocate();
        state = Error;
        return false;
    }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值