Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

libjpeg binary incompatibility between VIPS and OpenSlide #13

Open
Markus-PP opened this Issue May 31, 2017 · 3 comments

Comments

Projects
None yet
3 participants
Contributor

Markus-PP commented May 31, 2017

This just for the record, in case someone encounters the same problem.
We were using libvips with openslide on a Windows platform, and found that the libjpeg produced by libvips doesn't match the libjpeg interface produced by openslide-winbuild

The culprit is the following patch, described in line 200 of
https://github.com/jcupitt/build-win32/blob/master/7.34/vips.modules

the patch changes the "typedef int boolean" that libjpeg-turbo
provides, it causes problems later on for imagemagick

http://www.vips.ecs.soton.ac.uk/supported/7.30/win32/libjpeg-turbo-bool.patch

After this patch, in jmorecfg.h, boolean would be defined as unsigned char on libvips since V. 7.34, while on openslide, boolean remains an int
So, when the vips libjpeg is called from openslide, it correctly produces a JPEG parameter struct mismatch error.

As a workaround, insert the following line in jpeg) section in build.sh

    jpeg)
        sed -i 's/typedef int boolean/typedef unsigned char boolean/' jmorecfg.h

There might be other solutions, such as installing both DLLs and renaming one of them but I didn't look into it.

Markus-PP changed the title from libjpeg binary incompibility between VIPS and OpenSlide to libjpeg binary incompatibility between VIPS and OpenSlide May 31, 2017

Owner

bgilbert commented Jun 4, 2017

Hi @Markus-PP. Typically, folks who run VIPS on Windows use the OpenSlide DLL bundled with VIPS. You're seeing this problem because you're using openslide-winbuild to build a modified OpenSlide and then using it with VIPS. The workaround you described makes sense for your situation.

cc @jcupitt, who might know whether ImageMagick still needs that patch.

jcupitt commented Jun 5, 2017

Hello, I've not checked this patch for a while, perhaps it's no longer necessary. I'll have a look.

My memory is that:

  • we cross-compile the Windows binaries from linux using gcc and mingw
  • mingw used not to have a working intsafe.h implementation, so we were forced to stick with an older imagemagick
  • older imagemagicks don't use enum { FALSE, TRUE } for bool, they use typedef unsigned char bool, and assume sizeof(bool) == 1 in various places
  • libjpeg (and anything else that defines a global bool type) must therefore be patched

But perhaps one of these conditions has changed.

jcupitt commented Jun 5, 2017

Oh dear, it looks like typedef unsigned char boolean is a standard Windows thing, it's part of rpcndr.h, which is a platform include that ends up appearing in various packages. If libjpeg defines typedef int boolean, anything that includes libjpeg and the standard Windows headers (a great many packages) will see a compile error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment