Search code examples
c++libjpeg

Libjpeg 9b static lib on Ubuntu: JPEG parameter struct mismatch


I am using libjpeg ver.9b (static lib) in my JNI code. I have compiled everything successfully and got it running, until I touches the jpeg part. The console reads:

JPEG parameter struct mismatch: library thinks size is 664, caller expects 632

I have searched around and found most people pointing to duplicated shared libraries. I think I may rule this out as I have uninstalled all libjpeg libraries on the machine (no libjpeg.so remaining) and linked it statically into my code. The libjpeg library was built on the same machine following Compiling libjpeg and with CFLAGS="-O3 -fPIC". Any ideas where the issue is and how should I fix it?


Solution

  • This sounds like there might be still some headers of another version of the library left in the system. Did you uninstall the previous libraries by removing the packages using the packaging system, or just removed the libraries manually? (then the headers might still remain in the system - typically in /usr/include or /usr/local/include)

    In your other question, I don't see that you would provide the paths to the JPEG library explicitly on the command line. So unless you installed the library to default locations after building it, try to pass the include path explicitly by -I /path/to/correct_jpeg_headers.

    You can also try to find the locations of the other headers, for example by using:

    find /usr -name "jpeglib.h"
    

    Note that even though you link with the static library, it is still possible that the static library has been build with different headers than the client is using, so there still might be a structure mismatch (ODR violation) although it might link successfully.