gtk-rs / gtk

DEPRECATED, use https://github.com/gtk-rs/gtk3-rs repository instead!
https://gtk-rs.org/
MIT License
1.24k stars 82 forks source link

gtk 9 no longer builds on msvc #1032

Closed rukai closed 4 years ago

rukai commented 4 years ago

I have my machine setup as per https://web.archive.org/web/20191122174227/https://gtk-rs.org/docs-src/requirements.html Needing to use the internet archive to access important docs is a separate issue I guess...

gtk 8 builds fine but gtk 9 does not. Furthermore glib is the failing crate here which I tested independently, glib 9 builds fine but glib 10 fails. The error is:

error: failed to run custom build command for `glib-sys v0.10.0`

Caused by:
  process didn't exit successfully: `C:\Users\rukai\Projects\foo\target\release\build\glib-sys-1268d469ca4ba03d\build-script-build` (exit code: 1)
--- stderr
Failed to run `"pkg-config" "--libs" "--cflags" "glib-2.0" "glib-2.0 >= 2.42"`: The system cannot find the file specified. (os error 2)

warning: build failed, waiting for other jobs to finish...
error: build failed
sdroege commented 4 years ago

Those instructions are incomplete unfortunately. We should write proper instructions for Windows and update that. Please take a look at the GTK installation page though: https://www.gtk.org/docs/installations/windows/

You will also need pkg-config. This version for Windows works reasonably well: https://sourceforge.net/projects/pkgconfiglite/ . The pkg-config crate should ideally install that itself if not found on the system, see https://github.com/rust-lang/pkg-config-rs/issues/103.

Then you would point the PKG_CONFIG_PATH environment variable to the directory where GTK, GLib, etc are installed. It should be the full path to the subdirectory that contains the .pc files, e.g. glib-2.0.pc. This is usually the lib/pkgconfig subdirectory.

Once that is done everything should build correctly. If there are still problems, please let us know here (and also the content of the lib/pkgconfig directory and the output of pkg-config --libs gtk+-3.0). Thanks!

rukai commented 4 years ago

I installed pkgconfiglite via chocho install pkgconfiglite. Then I created the PKG_CONFIG_PATH as you described.

However its still failing, but this time with:

   Compiling glib-sys v0.10.0
error: failed to run custom build command for `glib-sys v0.10.0`

Caused by:
  process didn't exit successfully: `C:\Users\rukai\Projects\Foo\target\release\build\glib-sys-1268d469ca4ba03d\build-script-build` (exit code: 1)
--- stderr
`"pkg-config" "--libs" "--cflags" "glib-2.0" "glib-2.0 >= 2.42"` did not exit successfully: exit code: 1
--- stderr
Requested 'glib-2.0 >= 2.42' but version of GLib is

yes it just cuts off at the end there.

PS C:\Users\rukai\Projects\vcpkg\installed\x64-windows\lib\pkgconfig> ls

    Directory: C:\Users\rukai\Projects\vcpkg\installed\x64-windows\lib\pkgconfig

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----         5/07/2020   3:52 PM            323 epoxy.pc
-a----         5/07/2020   3:47 PM            425 gio-2.0.pc
-a----         5/07/2020   3:47 PM            330 gio-windows-2.0.pc
-a----         5/07/2020   3:47 PM            387 glib-2.0.pc
-a----         5/07/2020   3:47 PM            278 gmodule-2.0.pc
-a----         5/07/2020   3:47 PM            278 gmodule-export-2.0.pc
-a----         5/07/2020   3:47 PM            277 gmodule-no-export-2.0.pc
-a----         5/07/2020   3:47 PM            270 gobject-2.0.pc
-a----         5/07/2020   3:47 PM            232 gthread-2.0.pc
-a----         5/07/2020   3:46 PM            330 libpcre.pc
-a----         5/07/2020   3:46 PM            335 libpcre16.pc
-a----         5/07/2020   3:46 PM            335 libpcre32.pc
-a----         5/07/2020   3:46 PM            275 libpcrecpp.pc
-a----         5/07/2020   3:46 PM            318 libpcreposix.pc

PS C:\Users\rukai\Projects\vcpkg\installed\x64-windows\lib\pkgconfig> pkg-config --libs gtk+-3.0
Package gtk+-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk+-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtk+-3.0' found
PS C:\Users\rukai\Projects\vcpkg\installed\x64-windows\lib\pkgconfig> pkg-config --libs glib-2.0
-LC:/Users/rukai/Projects/vcpkg/installed/x64-windows/lib -lglib-2.0
PS C:\Users\rukai\Projects\vcpkg\installed\x64-windows\lib\pkgconfig>
sdroege commented 4 years ago

That's a bug in vcpkg, it's not installing pkg-config files for gtk apparently (but for glib it does). Please report this here: https://github.com/microsoft/vcpkg/

rukai commented 4 years ago

I submitted https://github.com/microsoft/vcpkg/issues/12282

However it looks like there is an additional issue as even glib by itself is failing, which should be fine as its pkgconfig files exist?

sdroege commented 4 years ago

How does glib fail, what happens if you run pkg-config --libs glib-2.0 or pkg-config --libs gobject-2.0?

sdroege commented 4 years ago

FWIW, the solution for now would be to either use GTK from msys2 or to build it yourself.

rukai commented 4 years ago

As mentioned in my previous comment:

   Compiling glib-sys v0.10.0
error: failed to run custom build command for `glib-sys v0.10.0`

Caused by:
  process didn't exit successfully: `C:\Users\rukai\Projects\Foo\target\release\build\glib-sys-1268d469ca4ba03d\build-script-build` (exit code: 1)
--- stderr
`"pkg-config" "--libs" "--cflags" "glib-2.0" "glib-2.0 >= 2.42"` did not exit successfully: exit code: 1
--- stderr
Requested 'glib-2.0 >= 2.42' but version of GLib is
PS C:\Users\rukai\Projects\vcpkg\installed\x64-windows\lib\pkgconfig> pkg-config --libs glib-2.0
-LC:/Users/rukai/Projects/vcpkg/installed/x64-windows/lib -lglib-2.0
sdroege commented 4 years ago

Ah sorry, missed that in the previous comment.

Requested 'glib-2.0 >= 2.42' but version of GLib is

This is cut off. What does pkg-config --modversion glib-2.0 say?

rukai commented 4 years ago

its empty:

PS C:\Users\rukai> pkg-config --modversion glib-2.0

PS C:\Users\rukai>
sdroege commented 4 years ago

Hm. Can you paste the content of glib-2.0.pc?

rukai commented 4 years ago
prefix=${pcfiledir}/../..
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include

glib_genmarshal=glib-genmarshal
gobject_query=gobject-query
glib_mkenums=glib-mkenums

Name: GLib
Description: C Utility Library
Version: 
Requires.private: 
Libs: -L${libdir} -lglib-2.0 
Libs.private:       
Cflags: -I${includedir}/glib-2.0 -I${libdir}/glib-2.0/include 

none of the other gtk .pc files have a version either.

sdroege commented 4 years ago

Ah so they exist but are completely broken, yay :) Can you create another vcpkg issue about that?

rukai commented 4 years ago

ok, i'll add it to the existing issue as they are very similar issues. Thanks for the assistance!

Kofituo commented 3 years ago

Those instructions are incomplete unfortunately. We should write proper instructions for Windows and update that. Please take a look at the GTK installation page though: https://www.gtk.org/docs/installations/windows/

You will also need pkg-config. This version for Windows works reasonably well: https://sourceforge.net/projects/pkgconfiglite/ . The pkg-config crate should ideally install that itself if not found on the system, see rust-lang/pkg-config-rs#103.

Then you would point the PKG_CONFIG_PATH environment variable to the directory where GTK, GLib, etc are installed. It should be the full path to the subdirectory that contains the .pc files, e.g. glib-2.0.pc. This is usually the lib/pkgconfig subdirectory.

Once that is done everything should build correctly. If there are still problems, please let us know here (and also the content of the lib/pkgconfig directory and the output of pkg-config --libs gtk+-3.0). Thanks!

I'm stuck over here with this problem

error: failed to run custom build command for glib-sys v0.10.1

Caused by: process didn't exit successfully: C:\Users\Dell\IdeaProjects\Swift_desktop\target\debug\build\glib-sys-3478cd927fc7fd67\build-script-build (exit code: 1) --- stdout cargo:rerun-if-env-changed=GLIB_2.0_NO_PKG_CONFIG cargo:rerun-if-env-changed=PKG_CONFIG cargo:rerun-if-env-changed=GLIB_2.0_STATIC cargo:rerun-if-env-changed=GLIB_2.0_DYNAMIC cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-pc-windows-msvc cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_pc_windows_msvc cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH cargo:rerun-if-env-changed=PKG_CONFIG_PATH cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-pc-windows-msvc cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_pc_windows_msvc cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-pc-windows-msvc cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_pc_windows_msvc cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

--- stderr "pkg-config" "--libs" "--cflags" "glib-2.0" "glib-2.0 >= 2.42" did not exit successfully: exit code: 1 --- stderr Requested 'glib-2.0 >= 2.42' but version of GLib is 2.28.8

GuillaumeGomez commented 3 years ago

The minimum supported version of GLib from gtk-rs is 2.42, which is more than 8 years old.