Windows 7上的png_set_read_fn()崩溃 [英] Crash in png_set_read_fn() on Windows 7

查看:340
本文介绍了Windows 7上的png_set_read_fn()崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我交叉编译Windows 7的一些C代码,并链接到libpng12.dll,找到此处。不幸的是,下面这行会导致崩溃(GDB表示分段错误):

pre pre $ png_structp png =空值);

我不确定从哪里开始调试 - 该函数看起来非常简单,并且与代码的其余部分。回溯曲线的顶部看起来像这样:

 #0 0xabababab in ?? ()
#1 0x6cc556d1 png_set_read_fn()from c:\ ... libpng12.dll
#2 0x6cc7a5d4 png_libpng_ver()from c:\ ... libpng12.dll
#3 0x00000038在? ()
#4 0x0028f928在? ()

我猜#4是png_create_read_struct(),因为#5是我称之为的函数。解决方案(不幸的是,通过试验和错误),但为了防止其他人遇到这个问题,它是由一个不正确的引起的。

zlib版本(在我的情况下,太旧了)。你可以在运行时很容易地检查它:

  fprintf(stderr,编译libpng%s;使用libpng%s。 \\\

PNG_LIBPNG_VER_STRING,png_libpng_ver);
fprintf(stderr,用zlib%s编译;使用zlib%s.\\\

ZLIB_VERSION,zlib_version);


I'm cross-compiling some C code for Windows 7 and linking to libpng12.dll found here. Unfortunately, the line below causes a crash (GDB says segmentation fault):

png_structp png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);

I'm not sure where to start to debug this--that function seems very straightforward and unrelated to the rest of the code. Top of the backtrace looks like this:

#0 0xabababab in ?? ()
#1 0x6cc556d1 in png_set_read_fn () from c:\...libpng12.dll
#2 0x6cc7a5d4 in png_libpng_ver () from c:\...libpng12.dll
#3 0x00000038 in ?? ()
#4 0x0028f928 in ?? ()

I guess #4 is png_create_read_struct(), since #5 is the function I call it from.

解决方案

Solved (unfortunately by trial & error) but just in case anyone else experiences this issue, it's caused by an incorrect version of zlib (in my case, too old). You can check for this quite easily at runtime:

fprintf(stderr, "   Compiled with libpng %s; using libpng %s.\n",
        PNG_LIBPNG_VER_STRING, png_libpng_ver);
fprintf(stderr, "   Compiled with zlib %s; using zlib %s.\n",
        ZLIB_VERSION, zlib_version);

这篇关于Windows 7上的png_set_read_fn()崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆