【问题标题】:fatal error LNK1181: cannot open input file 'gtk-3.lib'致命错误 LNK1181:无法打开输入文件 'gtk-3.lib'
【发布时间】:2020-10-14 15:00:35
【问题描述】:

所以我为 rust 设置了 GTK-rs,我一定做错了什么,因为当我尝试运行我的代码时,它返回了这个错误,我不知道如何修复它:

fatal error LNK1181: cannot open input file 'gtk-3.lib'

如果有帮助,我会使用 Eclipse IDE。

更多可能有帮助的数据:

我的环境变量是:

GTK_LIB_DIR=C:\msys64\mingw64\lib
PATH:
  C:\msys64\mingw64\bin
  C:\msys64\mingw64\include

我的 Cargo.toml 文件:

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


我使用了一些修改后的示例代码进行测试:

#![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: &gtk::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<_>>());
}

【问题讨论】:

    标签: rust gtk-rs


    【解决方案1】:

    在使用 gstreamer 和 gtk Rust 绑定时,我遇到了与“link.exe”相同的问题。这是我为编译程序所做的工作。

    除了检查“C++ 构建工具”时安装的“默认”工具外,下载 Microsoft 构建工具并安装以下工具。

    MS Build Tools Options - credit https://github.com/rust-lang/rust/issues/44787

    安装后,确保“C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\bin\Hostx64\x64”在您的环境路径中。

    重新启动您的电脑并再次尝试编译。希望它会奏效。但是,如果还是不行,我建议从 powershell 卸载 Rust

    rustup self uninstall
    

    然后以这种方式从 rustup.exe 重新安装 Rust。

    1. 运行 rustup.exe

    2. 当提示安装选项时,选择“自定义安装”

    3. 对于默认主机三元组选项类型

      stable-x86_64-pc-windows-gnu

    4. 按回车键选择“默认”选项,然后继续安装。

    重启你的电脑,程序肯定会编译。

    【讨论】:

    • 这并不能解决问题 - 甚至无法按照这些说明进行操作,因为当前工作负载索引中不存在您指定的选项。
    • @BadZen “当前工作负载指数”是什么意思?
    猜你喜欢
    • 2020-06-02
    • 1970-01-01
    • 2016-12-22
    • 1970-01-01
    • 2014-06-19
    • 1970-01-01
    • 2014-07-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多