gtk-rs / gtk

DEPRECATED, use https://github.com/gtk-rs/gtk3-rs repository instead!

Home Page:https://gtk-rs.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gtk 9 no longer builds on msvc

rukai opened this issue · comments

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

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 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>

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/

I submitted microsoft/vcpkg#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?

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

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

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

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?

its empty:

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

PS C:\Users\rukai>

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

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.

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

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

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

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