@@ -42,7 +42,19 @@ class << self
4242
4343 extend FFI ::Library
4444
45- ffi_lib library_name ( "glib-2.0" , 0 )
45+ if FFI ::Platform . windows?
46+ # On Windows, `GetProcAddress()` can only search in a specified DLL and
47+ # doesn't look into its dependent libraries for symbols. Therefore, we
48+ # check if the GLib DLLs are available. If these can not be found, we
49+ # assume that GLib is statically linked into libvips.
50+ ffi_lib [ "libglib-2.0-0.dll" , "libvips-42.dll" ]
51+ else
52+ # macOS and *nix uses `dlsym()`, which also searches for named symbols
53+ # in the dependencies of the shared library. Therefore, we can support
54+ # a single shared libvips library with all dependencies statically
55+ # linked.
56+ ffi_lib library_name ( "vips" , 42 )
57+ end
4658
4759 attach_function :g_malloc , [ :size_t ] , :pointer
4860
@@ -134,7 +146,11 @@ def self.set_log_domain domain
134146module GObject
135147 extend FFI ::Library
136148
137- ffi_lib library_name ( "gobject-2.0" , 0 )
149+ if FFI ::Platform . windows?
150+ ffi_lib [ "libgobject-2.0-0.dll" , "libvips-42.dll" ]
151+ else
152+ ffi_lib library_name ( "vips" , 42 )
153+ end
138154
139155 # we can't just use ulong, windows has different int sizing rules
140156 if FFI ::Platform ::ADDRESS_SIZE == 64
0 commit comments