gtk-rs / gtk4-rs

Rust bindings of GTK 4
https://gtk-rs.org/gtk4-rs/
MIT License
1.9k stars 174 forks source link

GTK-RS getting the wrong pkgconfig path in Windows #444

Closed Tryware closed 3 years ago

Tryware commented 3 years ago

I'm a Windows user and i used msys to build gtk4-rs. The problem is that msys creates a pkgconfig file named "pkg-config" instead of "pkg_config" and gtk-rs searches for "pkg_config" instead of "pkg-config".

sdroege commented 3 years ago

What do you mean with pkg_config? The name of the executable? That's just wrong.

But also the pkg-config of msys is known to be broken, see e.g. https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/#msys2-pacman

Tryware commented 3 years ago

Alright i'll check it. And yes i mean the name of the executable

oleid commented 3 years ago

I just successfully built some gtk4-rs demo app on windows, albeit with MSVC. And took notes. There is also a section on pkg-config, maybe it helps you. You need to change the path C:\GTK to whatever you used for installation.


The next tool you need is pkg-config. The build scripts of gtk-rs depend on it. It would seem the following is a stripped-down version without extra dependencies. Less is more here, so I used it: https://sourceforge.net/projects/pkgconfiglite/files/latest/download

All you need to to is to unpack it and add the executable to your system PATH. Or unpack it to somee folder which is already searched for executables.

To check if this worked, open x64 Native Tools Command Prompt for VS 2019 again and type:

C:\SomePath> pkg-config
Must specify package names on the command line

[...]

We need to tell pkg-config where to find the libraries we build before.


C:\Users\oleid\src\gtk4-rs>set PKG_CONFIG_PATH=C:\GTK\lib\pkgconfig

C:\Users\oleid\src\gtk4-rs>pkg-config --libs cairo
-LC:/GTK/lib -lcairo

https://gist.github.com/oleid/09f834e94acd63d46ba9ca810966bde2

Tryware commented 3 years ago

I just successfully built some gtk4-rs demo app on windows, albeit with MSVC. And took notes. There is also a section on pkg-config, maybe it helps you. You need to change the path C:\GTK to whatever you used for installation.

The next tool you need is pkg-config. The build scripts of gtk-rs depend on it. It would seem the following is a stripped-down version without extra dependencies. Less is more here, so I used it: https://sourceforge.net/projects/pkgconfiglite/files/latest/download

All you need to to is to unpack it and add the executable to your system PATH. Or unpack it to somee folder which is already searched for executables.

To check if this worked, open x64 Native Tools Command Prompt for VS 2019 again and type:

C:\SomePath> pkg-config
Must specify package names on the command line

[...]

We need to tell pkg-config where to find the libraries we build before.


C:\Users\oleid\src\gtk4-rs>set PKG_CONFIG_PATH=C:\GTK\lib\pkgconfig

C:\Users\oleid\src\gtk4-rs>pkg-config --libs cairo
-LC:/GTK/lib -lcairo

https://gist.github.com/oleid/09f834e94acd63d46ba9ca810966bde2

I got it working now, the application builds but now there's another problem which is a popup saying:

"Could not locate the entry point g_memdup2 procedure in the dynamic link library C:\msys64\mingw64\bin\libgtk-4-1.dll"

bilelmoussaoui commented 3 years ago

"Could not locate the entry point g_memdup2 procedure in the dynamic link library C:\msys64\mingw64\bin\libgtk-4-1.dll"

Seems like you're building an old gtk4 release. g_memdup2 was added in GLib 2.7 which is an unstable release but was backported to 2.66 see https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1927. So you need a newer GTK 4 built yourself or a newer GLib.

Tryware commented 3 years ago

"Could not locate the entry point g_memdup2 procedure in the dynamic link library C:\msys64\mingw64\bin\libgtk-4-1.dll"

Seems like you're building an old gtk4 release. g_memdup2 was added in GLib 2.7 which is an unstable release but was backported to 2.66 see https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1927. So you need a newer GTK 4 built yourself or a newer GLib.

My GLib version is exactly 2.68.2, and since the gtk4 version in the GTK4 Book wasn't working so i decided to use this one from (https://github.com/gtk-rs/gtk4-rs)

sdroege commented 3 years ago

Not an issue with the bindings but a general Windows build problem, so let's close this here.