Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit badc358

Browse files
Ensure compatibility with a single shared libvips library
See: #372.
1 parent 866f509 commit badc358

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

‎lib/vips.rb

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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
134146
module 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

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /