jcupitt / vipsdisp

Tiny libvips / gtk+4 image viewer
MIT License
130 stars 10 forks source link

VipsDisp 2.5.1 compiles on Windows, but does not run with VIPS 8.15.0 rc1 release #23

Closed vvinycity closed 9 months ago

vvinycity commented 10 months ago

I compiled VipsDisp 2.5.1 latest source release on Windows with new version of libvips (vips-dev-8.15.0 rc1). Previous version (8.14) cannot be used, because vips_thread_execute was added to API in 8.15. However, the executable does not run and gives an error "Procedure entry point g_regex_new could not be located in the dynamic link library libglib-2.0-0.dll" Dependency Walker shows that the entry point of g_regex_new in libglib-2.0-0.dll, supplied with 8.15 rc1 binary package, does not exist. So, it seems that this dll in 8.15.0 rc1 release is outdated. Where could I find libglib-2.0-0.dll with g_regex_new function defined?

jcupitt commented 10 months ago

I think the problem is that libvips and gtk both bundle libglib.dll, but they are not bundling the same version, and the libvips one does not have PCRE (perl-compatible regular expressions) enabled, since libvips does not need it.

You could try getting rid of the libglib.dll that came with libvips and using the gtk one instead, but you might hit other compat issues. The best solution is to build everything (all of gtk and all of libvips) from source.

jcupitt commented 10 months ago

I think I would approach a windows build by taking the build system for libvips:

https://github.com/libvips/build-win64-mxe

(that thing will download, patch, configure, build and install all 40-ish (!!) libraries that make up libvips)

And adding gtk4 and vipsdisp. I think (??) it's not as bad as it sounds since gtk4 can be built as a meson subproject. So maybe (maybe!) you can just add a subprojects folder to vipsdisp, put a gtk4 wrap file in there, and then when you run the mxe build it'll make a compatible gtk stack for you.

Alternatively, you can try just pasting the libvips and gtk4 precompiled binary zips together and see if you can make it work, but it's a bit dangerous and you might run into stability problems. The nip2 windows binary I made a while ago was a full stack build and used no precompiled components and I suspect that's probably the way to go.

jcupitt commented 10 months ago

Also, well done for attempting vipsdisp on windows. I think you're the first! I've been developing on ubuntu and testing on macos, but I've not been brave enough to attempt windows yet.

I'd be very interested to see how well it works.

vvinycity commented 10 months ago

Hi John,

Thank you very much for your suggestions, and above all, for your support. I will try to make this compile work and report back the results.

If you are curious why I am so much interested in reading big image files quickly, you might see the description of my image viewer (https://brainimaginginformatics.com/image-browser-3d-multi-modal-brain-viewer/2/). I wish libvips existed when I started that project.

Thanks again!

jcupitt commented 10 months ago

Oh, interesting, I worked on fetal brain imaging at Imperial, I was one of the people on dHCP:

https://www.developingconnectome.org

The nifti loader in libvips comes from that project.

jcupitt commented 10 months ago

One more suggestion, WSL2 supports GUI apps now, so you might be able to use the linux vipsdisp under Windows. Though I've not tried it. It would save a lot of building!

vvinycity commented 10 months ago

Hello, John. I would like to report some progress. Thinking about dependency problems, I decided to recompile VIPSDISP with static libvips using "vips-dev-8.15-static" binary package. Also, I moved the project to Windows 10 from Windows 7. The result is: the program runs but gives some errors. Please, see below a copy of these lines from shell window (chessboard.png is a small 3KB png image):

F:\OpenVDB_2016_01_15\VIPS\VIPS\vips-dev-8.15_static\bin>vipsdisp.exe chessboard.png

(process:7248): GLib-GObject-CRITICAL **: 01:43:21.319: g_object_new_is_valid_property: object class 'VipsdispApp' has no property named 'application-id'

(vipsdisp:7248): GLib-GIO-WARNING **: 01:43:21.365: win32 session dbus binary not found

(process:7248): GLib-GObject-CRITICAL **: 01:43:21.444: g_object_set_is_valid_property: object class 'VipsDraw' has no property named 'gtk-application-prefer-dark-theme'

(vipsdisp:7248): GLib-GIO-CRITICAL **: 01:43:21.459: This application can not open files.

Does it make any sense? What could be done about it?

jcupitt commented 10 months ago

That sounds perhaps like a gtk version mismatch. Which one are you using?

vvinycity commented 10 months ago

GTK4-1. Build from scratch with gvsbuild

jcupitt commented 10 months ago

Ah, vipsdisp is gtk4.10 or later only.

jcupitt commented 10 months ago

... I added the 4.10 requirement to meson https://github.com/jcupitt/vipsdisp/commit/35496349adf6463f4ea2ac73c0049a05edfe7dc9

vvinycity commented 10 months ago

Yes, gtk-4-1.dll

jcupitt commented 10 months ago

Maybe you have two glibs in there? The static libvips will have a glib inside, and maybe some parts of vipsdisp are linking to that and not to your gtk4 glib?

jcupitt commented 10 months ago

Yes, gtk-4-1.dll

I'm surprised there's no trailing zero, is this correct? vipsdisp needs gtk four dot ten, not four dot one. I have /usr/lib/x86_64-linux-gnu/libgtk-4.so.1.1000.4, ie. gtk 4.10.00, patch 4.

vvinycity commented 10 months ago

gvsbuild script created gtk-4-1.dll

kleisauke commented 10 months ago

See: https://github.com/jcupitt/vipsdisp/issues/21#issuecomment-1781504960.

In addition to compiling GLib with GRegex support, I also had to make a few changes to Cairo. https://github.com/libvips/build-win64-mxe/blob/64536f47ffa19aa4d66b9a024cf3d75133d66156/build/plugins/vipsdisp/overrides.mk#L3-L10

vvinycity commented 10 months ago

Unfortunately, I cannot use MXE. All my projects are in MSVC. So, to build GTK-4 I had to use gvsbuild (https://github.com/wingtk/gvsbuild).

jcupitt commented 10 months ago

I built it here (it took 1h20m!), but it doesn't work on my win10, unfortunately. It's in a VM and has no GPU acceleration, which I guess dooms it.

I put the binary it made here:

http://www.rollthepotato.net/~john/vips-dev-w64-all-8.15.0-rc1-disp.zip

Does that work for you, @vvinycity? You should be able to use some of the DLLs anyway.

vvinycity commented 10 months ago

Hello, John. Thank you very much! I tested VIPSDISP application. It runs. This is truly fantastic. JPEG mage 65500x35000 (~1.2 GB) opens in 15 to 20 seconds. Zooming in and out is smooth and instantaneous. Image scrolls in any direction painlessly, no delays, no rendering problems of any kind. There is one error message in cmd window and one warning: (vipsdisp:3036): GLib-GIO-CRITICAL : 23:51:58.779: GFileInfo created without standard::type (vipsdisp:3036): GLib-GIO-WARNING : 23:51:09.943: win32 session dbus binary not found

VISPDISP

Amazing! Now I will try to use VIPS library in my viewer. Thank you so much!

euzada commented 10 months ago

One more suggestion, WSL2 supports GUI apps now, so you might be able to use the linux vipsdisp under Windows. Though I've not tried it. It would save a lot of building!

Hi @jcupitt , I already tried it and it works but doesn't look smooth like native windows app and can't use it on another PC unless I activate wsl2. Now that I know it can works to building the windows version, I will definitely give it a try.

Btw, interesting how both of you works on the brain 🧠. I use libvips to stitch and visualize a semiconductor wafers.

jcupitt commented 10 months ago

I tried it on my wife's PC and it worked perfectly! That's so cool, nice work Kleis!

I made a formal 2.6.1 release and attached a zip.

https://github.com/jcupitt/vipsdisp/releases/tag/v2.6.1

In my VM with no GPU I see:

Untitled

So it's mostly working, just drawing the textures badly. The output window has:

Implementation unexpectedly missing WGL_ARB_extensions_string.  Probably a libepoxy bug.
(vipsdisp.exe:37828): GLib-WARNING **: 07:02:11.433: GError set over the top of a previous GError or uninitialized memory.
This indicates a bug in someone's code. You must ensure an error is NULL before it's set.
The overwriting error message was: WGL version 1.1 is too low, need at least 3.0
Gsk-Message: 07:02:11.433: Failed to realize renderer of type 'GskGLRenderer' for surface 'GdkWin32Toplevel': WGL version 1.1 is too low, need at least 3.0

Probably not worth investigating.

vvinycity commented 10 months ago

I am compiling sources from vipsdisp-2.6.1.zip in MSVC 2022 (Windows 10), and have these errors: error C2065: 'PACKAGE': undeclared identifier error C2065: 'APPLICATION_ID': undeclared identifier : error C2065: 'VERSION': undeclared identifier Is there some additional header which I am missing? Is this some environment configuration problem?

jcupitt commented 10 months ago

Those are defined by meson:

https://github.com/jcupitt/vipsdisp/blob/master/meson.build#L21-L29

They end up in config.h as #defines.

I would run meson yourself and get ninja to run your compiler. There are some notes here:

https://mesonbuild.com/Using-with-Visual-Studio.html

You can build libvips in the same way.

kleisauke commented 10 months ago

it took 1h20m!

Sorry about that, subsequent builds will be (hopefully) faster. The first time build needs to compile the whole of LLVM/Rust from source(!).

Failed to realize renderer of type 'GskGLRenderer' for surface 'GdkWin32Toplevel': WGL version 1.1 is too low, need at least 3.0

It looks like it needs at least a GPU with OpenGL 3.0 support. https://github.com/GNOME/gtk/blob/4.13.2/gdk/win32/gdkglcontext-win32-wgl.c#L396

(vipsdisp:3036): GLib-GIO-CRITICAL **: 23:51:58.779: GFileInfo created without standard::type

Not sure about this error, I haven't encountered this yet. It looks like it originates from: https://github.com/GNOME/glib/blob/2.78.1/gio/gfileinfo.c#L1611

Perhaps it conflicts with another libgio-2.0-0.dll available in the PATH env?

(vipsdisp:3036): GLib-GIO-WARNING **: 23:51:09.943: win32 session dbus binary not found

It looks like we need to distribute the gdbus.exe binary as well, I'll investigate.

euzada commented 10 months ago

Build VipsDisp 2.6.0 on windows using @kleisauke branch on libvips/build-win64-mxe.

jcupitt commented 10 months ago

Haha yes, I noticed the llvm compile, ouch.

Perhaps it conflicts with another libgio-2.0-0.dll available in the PATH env?

I tried again and I'm not seeing that error now. Sorry for the false alarm.

jcupitt commented 9 months ago

I think this is working now, and libvips 8.15 is out. I'll close.