6

我已经rustup-init.exe在我的 PC (Windows 10 Pro) 上安装了 Rust,然后安装了 Microsoft Visual C++ Build Tools 2017,并带有用于 CMake 选项的 Visual C++ 工具。

举个简单的例子,没有问题:

fn main() {
   println!("Hello world!");
}

我执行cargo run命令,结果我得到Hello world!了预期的结果。


但现在我想看看Azul GUI 框架

main.rs

extern crate azul;

fn main() {
   println!("Hello world!");
}

货运.toml

[package]
name = "my_first_azul_app"
version = "0.1.0"
authors = ["Author"]
edition = "2018"

[dependencies]
azul = { git = "https://github.com/maps4print/azul" }

当我执行cargo run命令时发生错误:

...

error: failed to run custom build command for `harfbuzz-sys v0.3.0 (https://github.com/maps4print/azul-dependencies?rev=c1548977fb62399f39aa642d2e7e24a24a25246e#c1548977)`
process didn't exit successfully: `C:\Users\admin\Documents\Rust\Projects\my_first_azul_app\target\debug\build\harfbuzz-sys-37196527d1c78dd0\build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-env-changed=HARFBUZZ_SYS_NO_PKG_CONFIG
running: "cmake" "C:\\Users\\admin\\.cargo\\git\\checkouts\\azul-dependencies-70bb1f94316762f9\\c154897\\harfbuzz-sys-0.3.0\\harfbuzz" "-G" "Visual Studio 15 2017 Win64" "-Thost=x64" "-DCMAKE_INSTALL_PREFIX=C:\\Users\\admin\\Documents\\Rust\\Projects\\my_first_azul_app\\target\\debug\\build\\harfbuzz-sys-9193f770b45e8642\\out" "-DCMAKE_C_FLAGS= /nologo /MD" "-DCMAKE_C_FLAGS_DEBUG= /nologo /MD" "-DCMAKE_CXX_FLAGS= /nologo /MD" "-DCMAKE_CXX_FLAGS_DEBUG= /nologo /MD" "-DCMAKE_BUILD_TYPE=Debug"

--- stderr
thread 'main' panicked at '
failed to execute command: cannot find the file specified. (os error 2)
is `cmake` not installed?

...

如何用 CMake 和 Rust 解决这个问题?我应该指定 CMake 路径吗?

4

1 回答 1

12

我通过将 CMake bin 添加到 PATH 变量中来解决它。刚刚在最近安装的 Visual Studio Build Tools 目录中搜索cmake.exe文件或文件夹,发现CMakecmake.exe

对我来说是C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin

这样我就不必单独安装 CMake。

我还在 Visual Studio 构建工具的安装过程中添加了 Windows 10 SDK 复选框。

现在构建我的项目时没有错误。我希望这可以帮助别人。

于 2019-03-21T22:18:01.700 回答