So I set up GTK-rs for rust and I must have done something wrong because when I try to run my code it returns this error and I have no idea how to fix it:
fatal error LNK1181: cannot open input file 'gtk-3.lib'
I use Eclipse IDE if that will help.
Some more data that might help:
My environment variables are:
GTK_LIB_DIR=C:\msys64\mingw64\lib
PATH:
C:\msys64\mingw64\bin
C:\msys64\mingw64\include
My Cargo.toml file:
[package]
name = "myapp"
version = "0.1.0"
authors = ["author"]
edition = "2018"
[dependencies.gtk]
version = "0.9.2"
features = ["v3_16"]
[dependencies]
glib = "0.10.2"
gio = "0.9.1"
I used some modified sample code for testing:
#![allow(non_snake_case)]
extern crate gtk;
extern crate glib;
extern crate gio;
use gio::prelude::*;
use glib::clone;
use gtk::prelude::*;
// When the application is launched…
fn on_activate(application: >k::Application) {
// … create a new window …
let window = gtk::ApplicationWindow::new(application);
// … with a button in it …
let button = gtk::Button::with_label("Hello World!");
// … which closes the window when clicked
button.connect_clicked(clone!(@weak window => move |_| window.close()));
window.add(&button);
window.show_all();
}
fn main() {
// Create a new application
let app = gtk::Application::new(Some("com.github.gtk-rs.examples.basic"), Default::default())
.expect("Initialization failed...");
app.connect_activate(|app| on_activate(app));
// Run the application
app.run(&std::env::args().collect::<Vec<_>>());
}
I was having the same problem with "link.exe" when using gstreamer and gtk Rust bindings. Here's what I did to make my program compile.
Download Microsoft Build Tools and install the following in addition to the 'default' tools that are installed when checking the "C++ build tools".
MS Build Tools Options - credit https://github.com/rust-lang/rust/issues/44787
After the installation, make sure that "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC<VC Version>\bin\Hostx64\x64" is in your environment path.
Restart your pc and try compiling again. Hopefully it is going to work. However, if it still doesn't, I recommend uninstalling Rust from powershell
And then reinstalling Rust from the rustup.exe in this way.
Run rustup.exe
When prompted with the install option, select "customize installation"
For default host triples option type
stable-x86_64-pc-windows-gnu
Press enter for 'default' options for the rest and continue installation.
Restart your pc and the program is definitely going to compile.