mr.*_*ris 6 cmake rust rust-cargo visual-studio-2017-build-tools
我已经rustup-init.exe
在我的 PC(Windows 10 专业版)上安装了 Rust,然后在 Microsoft Visual C++ Build Tools 2017 上安装了 CMake 选项的 Visual C++ 工具。
举个简单的例子,没有问题:
fn main() {
println!("Hello world!");
}
Run Code Online (Sandbox Code Playgroud)
我执行cargo run
命令,结果我得到Hello world!
了预期的结果。
但现在我想看看Azul GUI 框架
主文件
extern crate azul;
fn main() {
println!("Hello world!");
}
Run Code Online (Sandbox Code Playgroud)
Cargo.toml
[package]
name = "my_first_azul_app"
version = "0.1.0"
authors = ["Author"]
edition = "2018"
[dependencies]
azul = { git = "https://github.com/maps4print/azul" }
Run Code Online (Sandbox Code Playgroud)
当我执行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?
...
Run Code Online (Sandbox Code Playgroud)
如何使用 CMake 和 Rust 解决此问题?我应该指定 CMake 路径吗?
mr.*_*ris 12
我通过将 CMake bin 添加到 PATH 变量中来解决它。刚刚在最近安装的 Visual Studio Build Tools 目录中搜索cmake.exe
文件或CMake
文件夹,发现cmake.exe
对我来说是 C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin
这样我就不必单独安装 CMake。
我还在 Visual Studio Build Tools 的安装过程中添加了 Windows 10 SDK 复选框。
现在构建我的项目时没有错误。我希望这可以帮助别人。