@@ -245,13 +245,8 @@ private static function init(): void
245245 }
246246
247247 $ vips_libname = self ::libraryName ("libvips " , 42 );
248- if (PHP_OS_FAMILY === "Windows " ) {
249- $ glib_libname = self ::libraryName ("libglib-2.0 " , 0 );
250- $ gobject_libname = self ::libraryName ("libgobject-2.0 " , 0 );
251- } else {
252- $ glib_libname = $ vips_libname ;
253- $ gobject_libname = $ vips_libname ;
254- }
248+ $ glib_libname = self ::libraryName ("libglib-2.0 " , 0 );
249+ $ gobject_libname = self ::libraryName ("libgobject-2.0 " , 0 );
255250
256251 Utils::debugLog ("init " , ["library " => $ vips_libname ]);
257252
@@ -771,21 +766,24 @@ private static function init(): void
771766 }
772767
773768 Utils::debugLog ("init " , ["binding ... " ]);
774- self ::$ glib = self ::libraryLoad (
775- $ libraryPaths ,
776- $ glib_libname ,
777- $ glib_decls
778- );
779- self ::$ gobject = self ::libraryLoad (
780- $ libraryPaths ,
781- $ gobject_libname ,
782- $ gobject_decls
783- );
784- self ::$ vips = self ::libraryLoad (
785- $ libraryPaths ,
786- $ vips_libname ,
787- $ vips_decls
788- );
769+ 770+ /**
771+ * We can sometimes get dependent libraries from libvips -- either the platform
772+ * will open dependencies for us automatically, or the libvips binary has been
773+ * built to includes all main dependencies (common on Windows, can happen
774+ * elsewhere).
775+ *
776+ * We must get GLib functions from libvips if we can, since it will be the
777+ * one that libvips itself is using, and they will share runtime types.
778+ */
779+ self ::$ glib =
780+ self ::libraryLoad ($ libraryPaths , $ vips_libname , $ glib_decls ) ??
781+ self ::libraryLoad ($ libraryPaths , $ glib_libname , $ glib_decls );
782+ self ::$ gobject =
783+ self ::libraryLoad ($ libraryPaths , $ vips_libname , $ gobject_decls ) ??
784+ self ::libraryLoad ($ libraryPaths , $ gobject_libname , $ gobject_decls );
785+ 786+ self ::$ vips = self ::libraryLoad ($ libraryPaths , $ vips_libname , $ vips_decls );
789787
790788 # Useful for debugging
791789 # self::$vips->vips_leak_set(1);
0 commit comments