@@ -249,13 +249,8 @@ private static function init(): void
249249 }
250250
251251 $ vips_libname = self ::libraryName ("libvips " , 42 );
252- if (PHP_OS_FAMILY === "Windows " ) {
253- $ glib_libname = self ::libraryName ("libglib-2.0 " , 0 );
254- $ gobject_libname = self ::libraryName ("libgobject-2.0 " , 0 );
255- } else {
256- $ glib_libname = $ vips_libname ;
257- $ gobject_libname = $ vips_libname ;
258- }
252+ $ glib_libname = self ::libraryName ("libglib-2.0 " , 0 );
253+ $ gobject_libname = self ::libraryName ("libgobject-2.0 " , 0 );
259254
260255 Utils::debugLog ("init " , ["library " => $ vips_libname ]);
261256
@@ -775,21 +770,24 @@ private static function init(): void
775770 }
776771
777772 Utils::debugLog ("init " , ["binding ... " ]);
778- self ::$ glib = self ::libraryLoad (
779- $ libraryPaths ,
780- $ glib_libname ,
781- $ glib_decls
782- );
783- self ::$ gobject = self ::libraryLoad (
784- $ libraryPaths ,
785- $ gobject_libname ,
786- $ gobject_decls
787- );
788- self ::$ vips = self ::libraryLoad (
789- $ libraryPaths ,
790- $ vips_libname ,
791- $ vips_decls
792- );
773+
774+ /**
775+ * We can sometimes get dependent libraries from libvips -- either the platform
776+ * will open dependencies for us automatically, or the libvips binary has been
777+ * built to includes all main dependencies (common on Windows, can happen
778+ * elsewhere).
779+ *
780+ * We must get GLib functions from libvips if we can, since it will be the
781+ * one that libvips itself is using, and they will share runtime types.
782+ */
783+ self ::$ glib =
784+ self ::libraryLoad ($ libraryPaths , $ vips_libname , $ glib_decls ) ??
785+ self ::libraryLoad ($ libraryPaths , $ glib_libname , $ glib_decls );
786+ self ::$ gobject =
787+ self ::libraryLoad ($ libraryPaths , $ vips_libname , $ gobject_decls ) ??
788+ self ::libraryLoad ($ libraryPaths , $ gobject_libname , $ gobject_decls );
789+
790+ self ::$ vips = self ::libraryLoad ($ libraryPaths , $ vips_libname , $ vips_decls );
793791
794792 # Useful for debugging
795793 # self::$vips->vips_leak_set(1);
0 commit comments