Failed to run pkg-config with Rust and GTK on Windows

Viewed 2072

I have started programming in Rust recently and I love it <3.

I want to make a small desktop application with Rust and GTK. I am on a Windows machine, but I am facing a problem while setting up my environment.

I followed these tutorials:

I implemented the code. I am MSYS2 as GTK deliverant. I followed these tutorials step by step, but when I try to compile the code, I get the following error message:

"Failed to run `"pkg-config" "--libs" "--cflags" "glib-2.0" "glib-2.0 >= 2.44"`: The System cant find the given file. (os error 2)"

My project working directory looks like this:

.  project
├─ Cargo.lock
├─ Cargo.toml
├─ src/
│  └─ main.rs
└─ target/

I've currently not set the MSYS2 Directory as PATH variable. I've tried this before but with no result.

Does anyone have an idea on how to solve it?

2 Answers

I think I solved it. I followed along the mentioned tutorials. After that one i set the Variable

GTK_LIB_DIR=C:\msys64\mingew64\bin PKG_CONFIG_ALLOW_CROSS=1

And set the follwing variable to PATH

C:\msys64\mingw64\bin

After that, dont forget to restart the Pc, i had quit a Problem with this one. Becuase the variables werent correctly propagated.

I am using the dependecies and features of the following .toml from github. With this i am compiling for the given feature of gtk_3_24 and for the target=x86_64-pc-windows-gnu. So the command looks as following.

cargo run --features gtk_3_24 --target=x86_64-pc-windows-gnu

With this, all works fine :).

In my case, what resolved it was the solution here, namely

pacman -S mingw-w64-x86_64-pkg-config

or

pacman -S mingw-w64-i686-pkg-config

Related