JPEG 参数结构不匹配 [英] JPEG parameter struct mismatch

查看:33
本文介绍了JPEG 参数结构不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在编译 libjpeg 然后使用它之后,我偶然发现了这个问题:

Ater compiling libjpeg and then using it, I stumbled upon the problem:

JPEG parameter struct mismatch: library thinks size is 512, caller expects 492

之后程序停止.这特别发生在结构 struct jpeg_decompress_structstruct jpeg_compress_struct 上.如果取消对这些结构的检查,程序会因空指针异常而崩溃,并且结构成员包含垃圾.

after which the program halts. This happens specifically with the structs struct jpeg_decompress_struct and struct jpeg_compress_struct. If the checks are removed on these structs, the program crashes with a null pointer exception, and the struct members contain garbage.

错误发生在版本 6b 的预编译二进制文件,或预编译版本 9a 和编译版本 9a 中;在 Windows(32 位)上使用 MinGW、MSYS 1.0 编译.在配置文件中乱搞无济于事;数字 492 可以更改,但永远不会等于 512,以便程序正常运行.

The error occurs with either precompiled binaries from version 6b, or with precompiled version 9a, and with the compiled version 9a; compiled with MinGW, MSYS 1.0, on windows (32 bit). Messing around in the config files does not help; the number 492 can change, but never equals 512 in order for the program to function.

libjpeg 编译确实创建了一个有效的 cjpeg.exedjpeg.exe.

The libjpeg compilation did create a valid cjpeg.exe and djpeg.exe.

有什么想法吗?

推荐答案

就我而言,问题是库和我的程序是用不同的 HAVE_BOOLEAN 值编译的,所以 boolean 类型有不同的大小.

In my case, the problem was that the library and my program were compiled with different values of HAVE_BOOLEAN, so boolean type had different size.

库是在未定义 HAVE_BOOLEAN 的情况下编译的,因此它使用了 libjpeg 中定义的 int.程序编译时定义了 HAVE_BOOLEAN,并且因为在 libjpeg 之前包含了一些其他头文件,所以它使用了 Windows RTL 中定义的 unsigned char.

Library was compiled with HAVE_BOOLEAN not defined, so it was using int as defined in libjpeg. Program was compiled with HAVE_BOOLEAN defined, and because some other headers were included before libjpeg, it was using unsigned char as defined in Windows RTL.

我使用 HAVE_BOOLEAN 的原因是为了修复关于此的编译错误,但它随后导致了链接器错误.相反,正确的解决方案是在使用 libjpeg 的文件中不包含 Windows RTL(或任何包含它的文件).

Reason I used HAVE_BOOLEAN was to fix compile error about this, but it then caused a linker error. Instead, the proper solution was to not include Windows RTL (or any file that includes it) in the file that uses libjpeg.

这篇关于JPEG 参数结构不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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