Skip to content

Commit

Permalink
Ensure compatibility with a single shared libvips library
Browse files Browse the repository at this point in the history
See: #372.
  • Loading branch information
kleisauke committed Mar 4, 2024
1 parent 866f509 commit 9e662fe
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions lib/vips.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,19 @@ class << self

extend FFI::Library

ffi_lib library_name("glib-2.0", 0)
if FFI::Platform.windows?
# On Windows, `GetProcAddress()` can only search in a specified DLL and
# doesn't look into its dependent libraries for symbols. Therefore, we
# check if the GLib DLLs are available. If these can not be found, we
# assume that GLib is statically linked into libvips.
ffi_lib ['libglib-2.0-0.dll', 'libvips-42.dll']
else
# macOS and *nix uses `dlsym()`, which also searches for named symbols
# in the dependencies of the shared library. Therefore, we can support
# a single shared libvips library with all dependencies statically
# linked.
ffi_lib library_name("vips", 42)
end

attach_function :g_malloc, [:size_t], :pointer

Expand Down Expand Up @@ -134,7 +146,11 @@ def self.set_log_domain domain
module GObject
extend FFI::Library

ffi_lib library_name("gobject-2.0", 0)
if FFI::Platform.windows?
ffi_lib ['libgobject-2.0-0.dll', 'libvips-42.dll']
else
ffi_lib library_name("vips", 42)
end

# we can't just use ulong, windows has different int sizing rules
if FFI::Platform::ADDRESS_SIZE == 64
Expand Down

0 comments on commit 9e662fe

Please sign in to comment.