Closed jcupitt closed 2 years ago
This would provide it: https://github.com/GNOME/glib/blob/main/glib/gmem.c ...which reads:
Since GLib 2.46
g_malloc()
is hardcoded to always use the systemmalloc
implementation.
Also concerning g_free()
...does one even needs a library for that?
It's a historical accident -- glib used (10+ years ago) to have its own malloc implementation, and therefore needed its own free. These days they just use the platform malloc (thank goodness). You still need to use the g_*()
versions though.
I'm not exactly sure if the G stands for GNU or GNOME, ... but the target system might be missing the library: http://www.gnu.org/software/libc/libc.html
Hey guys! Could you give me advice how to statically link libvips with glib? I have the same issue with g_* functions.
This commit is also relevant here: https://github.com/kleisauke/net-vips/commit/e04c6b0997130f06a4af2bf66c9055a529024dd1. I think there are at least 3 ways to solve this (ordered from easy to difficult):
libglib-2.0-0.dll
and libgobject-2.0-0.dll
respectively as the name of the shared library on Windows. This is not necessary on Linux and macOS.single-shared
branch.g_object_unref
becomes vips_object_unref
, see: https://github.com/libvips/libvips/discussions/2788). This would also require an update to the binding to use this new API.Note that point 2 would break compatibility with the shared Windows builds, plus all libvips bindings based on FFI needs to be updated to avoid libglib-2.0-0.dll
and libgobject-2.0-0.dll
. Point 3 has the same disadvantages as point 2, plus would break backwards compatibility with older libvips versions (as it uses those new symbols).
Since this is only a issue on Windows, I think point 1 is the most straightforward. I might look into making a PR somewhere tomorrow.
I just opened PR https://github.com/libvips/php-vips/pull/146 for this. Any testing would be welcome (especially on Windows 32-bit).
@kleisauke just tested your PR on x64 Windows (currently I don't have win x86). It works fine!
Config.php
tries to link tog_malloc
andg_free
(glib functions) in the libvips shared library. This works on linux, since it can resolve indirect dependencies, but maybe windows needs the exact shared library that contains the named function.Experiment with directly linking to glib and gobject.
ruby-vips
does this and seems to work on windows.See: https://stackoverflow.com/questions/72330264/libvips-ffi-use-on-windows-php-cannot-find-glib-functions