my application uses libjpeg to read/write JPEG-images. everything worked fine
recently my app started to crash when trying to write JPEG images with an error “Wrong JPEG library version: library is 80, caller expects 62” when calling jpeg_create_compress() (so the crash seems to be an intentional abort on the libjpeg side rather than a segfault)
a bit of investigation showed that indeed my application was compiled against libjpeg-62 headers (that were installed in /usr/local/include) and was then using the dylibs from libjpeg-80 (installed in /usr/lib/i386-linux-gnu/).
removing the libjpeg-62 headers and compiling using the libjpeg-80 headers solved the problem.
however, i would appreciate a solution that would allow me to prevent such crashes, even if some end-user has a different library version installed than my app was compiled against.
1) it would be great if i could somehow convince libjpeg to not abort even on fatal errors;
e.g. something like:
jpeg_abort_on_error(0);
2) or have a non-aborting check whether the correct library is installed:
if(!jpeg_check_libraryversion()) return;
3) if that’s not doable out of the box, i’m fine with manually checking the compile-time API-version (JPEG_LIB_VERSION) against a compat-version detected at runtime.
unfortunately i have not been able to find anything in the API that would allow me to use either of those methods.
am i just blind or do i need a something completely different?
setting up an error-handler for error_exit prevents the application from crashing.
(my problem was that i had this done for the load-functionality, but not for the save-functionality, hence it exited when there were problems during saving).
something like the following did the trick: