JPEG parameter struct mismatch
Asked Answered
B

2

6

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

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

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.

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.

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

Any ideas?

Bibbs answered 7/4, 2014 at 23:55 Comment(6)
This sounds like you've got two (or more) versions of libjpeg installed. The headers must match the library; check to make sure your include paths and library paths sync up.Coparcener
#4306686 look at the source, find the struct, and see if there is a way to make it right using these build toolsTepper
the version can be OK, there is a check for JPEG_LIB_VERSION before the check for the size of the structTepper
Maybe just try to add __attribute__ ((__packed__)) attribute to the structs, so they might get packed to 492 bytes, as the caller expects.Tepper
The packed attribute did not compact them to 492 but to 508Bibbs
Please check if you have multiple copies of libjpeg installed. point the one which is throwing the error to the correct copy of libjpeg using linking i.e ln -s command.Exceedingly
S
1

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.

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.

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.

Sheer answered 1/4, 2019 at 10:18 Comment(0)
D
0

It seems that the static package architecture does not conform to the current package architecture when the linker is connected. It is recommended to download the source code and compile it into a static library with the same parameters. Try again, remember to quote the correct version.

Disenfranchise answered 21/8, 2019 at 8:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.