I have a single main.rs file. When I compile it by cargo run, I get an error:
error: linking with `cc` failed: exit status: 1
= note: ld: library not found for -lgtk-3
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I wanted to make a new window with titled "hello world". But when I run the program it gives me this error I've seen some topic related to this one but none of them helped me to solve the problem.
My code:
extern crate gtk;
use gtk::*;
pub struct Application {
pub window: Window,
pub header: Header,
}
pub struct Header {
pub container: HeaderBar,
}
impl Application {
fn new() -> Application {
let window = Window::new(WindowType::Toplevel);
let header = Header::new();
window.set_titlebar(&header.container);
window.set_title("Простая программа");
window.set_wmclass("simple-gtk", "Простая программа");
Window::set_default_icon_name("имя иконки");
window.connect_delete_event(move |_, _| {
main_quit();
Inhibit(false)
});
Application { window, header }
}
}
impl Header {
fn new() -> Header {
let container = HeaderBar::new();
container.set_title("Простая программа");
container.set_show_close_button(true);
Header { container }
}
}
fn main() {
if gtk::init().is_err() {
eprintln!("Не удалось инициализировать GTK приложение.");
return;
}
let app = Application::new();
app.window.show_all();
gtk::main();
}
My cargo.toml
[package]
name = "hello_world"
version = "0.1.0"
authors = ["Yura Martyr"]
[dependencies]
[dependencies.gtk]
version = "0.3.0"
features = ["v3_22"]