在git上下载了一个rust项目,使用了winapi
代码段: extern crate gdi32; extern crate user32; use winapi::{ RECT, SW_SHOW}; use winapi::winnt::{ LPCWSTR, HANDLE }; use winapi::minwindef::{UINT, DWORD, WPARAM, LPARAM, LRESULT, HINSTANCE };
编译出现
Compiling sweepers v0.1.0 (file:///E:/mywork/rust/sweepers)
error[E0432]: unresolved import winapi::RECT
--> src\devices.rs:3:15
|
3 | use winapi::{ RECT, SW_SHOW};
| ^^^^ no RECT
in the root
查资料:https://docs.rs/winapi/*/x86_64-pc-windows-msvc/winapi/shared/windef/index.html 发现是Module winapi::shared::windef
于是代码修改为: extern crate gdi32; extern crate user32;
use winapi::shared; use winapi::shared::windef; use winapi::shared::windef::RECT;
编译出现
Compiling sweepers v0.1.0 (file:///E:/mywork/rust/sweepers)
error[E0432]: unresolved import winapi::shared::windef
--> src\devices.rs:5:5
|
5 | use winapi::shared::windef;
| ^^^^^^^^^^^^^^^^^^^^^^ no windef
in shared
error[E0432]: unresolved import winapi::shared::windef
--> src\devices.rs:6:21
|
6 | use winapi::shared::windef::RECT;
| ^^^^^^ Could not find windef
in shared
我是差了什么东西吗?
https://crates.io/crates/winapi 提到过 Windows 10 SDK 这个东西,难道需要安装这个?
评论区
写评论之前在群里说过啦,这里的代码依赖的是 winapi 0.2
弄一下格式