From ae4046b5a5501daa53f2c5889ad0c1482cf9ac8d Mon Sep 17 00:00:00 2001 From: Thomas Meson Date: Tue, 8 Sep 2015 14:31:12 +0200 Subject: [PATCH 1/2] vips.h: fail to build on Debian Jessie Debian Jessie has libvips 7.40.6. Problem is that before 7.41, VIPS_ANGLE_DXX did not exists. So we need to define properly the macro in order to build for libvips < 7.41 --- vips.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/vips.h b/vips.h index a97fe20..9f2e101 100644 --- a/vips.h +++ b/vips.h @@ -64,6 +64,18 @@ vips_shrink_bridge(VipsImage *in, VipsImage **out, double xshrink, double yshrin int vips_rotate(VipsImage *in, VipsImage **out, int angle) { +#if (VIPS_MAJOR_VERSION == 7 && VIPS_MINOR_VERSION < 41) +/* + * Starting libvips 7.41, VIPS_ANGLE_x has been renamed to VIPS_ANGLE_Dx + * "to help python". So we provide the macro to correctly build for versions + * before 7.41.x. + * https://github.com/jcupitt/libvips/blob/master/ChangeLog#L128 + */ +# define VIPS_ANGLE_D0 VIPS_ANGLE_0 +# define VIPS_ANGLE_D90 VIPS_ANGLE_90 +# define VIPS_ANGLE_D180 VIPS_ANGLE_180 +# define VIPS_ANGLE_D270 VIPS_ANGLE_270 +#endif int rotate = VIPS_ANGLE_D0; if (angle == 90) { From 0e5ba538470a47585009c5818f78281fcda24594 Mon Sep 17 00:00:00 2001 From: Thomas Meson Date: Tue, 8 Sep 2015 14:31:54 +0200 Subject: [PATCH 2/2] vips.h: problem with vips_init() For version prior 7.41, vips_init() is a macro to VIPS_INIT(). VIPS_INIT() should be called, but as it is a macro, cgo could not determine the return type, hence making the build fail. So, we undef vips_init(), and define the vips_init() method. --- vips.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/vips.h b/vips.h index 9f2e101..c264bc4 100644 --- a/vips.h +++ b/vips.h @@ -31,6 +31,25 @@ typedef struct { double Background[3]; } WatermarkOptions; +/* + * This method is here to handle the weird initialization of the vips lib. + * libvips use a macro VIPS_INIT() that call vips__init() in version < 7.41, + * or calls vips_init() in version >= 7.41. + * Anyway, it's not possible to build bimg on Debian Jessie with libvips 7.40.x, + * as vips_init() is a macro to VIPS_INIT(), which is also a macro, hence, cgo + * is unable to determine the return type of vips_init(), making the build impossible. + * In order to correctly build bimg, for version < 7.41, we should undef vips_init and + * creates a vips_init() method that calls VIPS_INIT(). + */ +#if (VIPS_MAJOR_VERSION == 7 && VIPS_MINOR_VERSION < 41) +# undef vips_init +int +vips_init(const char *argv0) +{ + return VIPS_INIT(argv0); +} +#endif + void vips_enable_cache_set_trace() {