Rust GUI库的摸索

tauri

最开始用的

1
2
[dependencies]
tauri = "latest"

但是环境配置似乎需要msvc,我用的gnu,导致编译总是报错

这个tauri最开始是做 perf-in 项目打算用的。

iced

目前我在考虑鼠标轨迹记录程序用rust重写。

尝试使用

1
2
[dependencies]
iced = "0.3"

这个库,看上去写法和代码很现代化,跨平台。

但是编译还是报错,似乎还是要msvc,可能有点复杂了

fltk

于是又换了一个更简单轻量级的

1
2
[dependencies]
fltk = "1.2"

结果编译又报错了:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
D:\Projects\Project-Test\rust-ui-test>cargo build
Compiling cc v1.0.90
Compiling crossbeam-utils v0.8.19
Compiling paste v1.0.14
Compiling ttf-parser v0.20.0
Compiling bitflags v2.5.0
Compiling cmake v0.1.50
Compiling crossbeam-channel v0.5.12
Compiling fltk-sys v1.4.28
The following warnings were emitted during compilation:

warning: fltk-sys@1.4.28: Could not find invokable cmake!

error: failed to run custom build command for `fltk-sys v1.4.28`

Caused by:
process didn't exit successfully: `D:\Projects\Project-Test\rust-ui-test\target\debug\build\fltk-sys-13537af21141788d\build-script-main` (exit code: 101)
--- stdout
cargo:rerun-if-changed=build/android.rs
cargo:rerun-if-changed=build/bundled.rs
cargo:rerun-if-changed=build/link.rs
cargo:rerun-if-changed=build/main.rs
cargo:rerun-if-changed=build/source.rs
cargo:rerun-if-changed=build/utils.rs
cargo:rerun-if-changed=build/fltk_config.rs
cargo:rerun-if-changed=build/pkg_config.rs
cargo:warning=Could not find invokable cmake!

--- stderr
thread 'main' panicked at D:\Rust\cargo_home\registry\src\index.crates.io-6f17d22bba15001f\fltk-sys-1.4.28\build/main.rs:57:13:
CMake was not found. It's needed to build fltk and cfltk.
Perhaps you would prefer to use a bundled version of fltk.
You would need to enable the fltk-bundled feature.
Or if you have an installation of FLTK 1.4 and a working fltk-config executable, you can use the fltk-config feature.
Features can be enabled in your Cargo.toml or from the command line using the --features=fltk/fltk-bundled argument to cargo.
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

尝试的解决方法:

先去安装cmake

1
https://cmake.org/download/#latest

需要保证camke在环境变量PATH里,所以安装的时候要勾选一下。

装好cmake之后再编译,报错更猛烈了。

改用

1
2
[dependencies]
fltk = { version = "1.2", features = ["fltk-bundled"] }

试了之后还是报错:

1
2
3
4
5
error: linking with `x86_64-w64-mingw32-gcc` failed: exit code: 1
|
= note: "x86_64-w64-mingw32-gcc" "-fno-use-linker-plugin" "-Wl,--dynamicbase" "-Wl,--disable-auto-image-base" "-m64" "-Wl,--high-entropy-va" "D:\\Rust\\rustup_home\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\self-contained\\crt2.o" "D:\\Rust\\rustup_home\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsbegin.o" "C:\\Users\\LITTLE~1\\AppData\\Local\\Temp\\rustceJbft8\\symbols.o" "D:\\Projects\\Project-Test\\rust-ui-test\\target\\debug\\deps\\rust_ui_test-158b451f6cadf32d.2hxomignw9av32oe.rcgu.o" "D:\\Projects\\Project-Test\\rust-ui-test\\target\\debug\\deps\\rust_ui_test-158b451f6cadf32d.35wuskz0ujdg8ofw.rcgu.o" "D:\\Projects\\Project-Test\\rust-ui-test\\target\\debug\\deps\\rust_ui_test-158b451f6cadf32d.3njzyxeemufjkbjh.rcgu.o" "D:\\Projects\\Project-Test\\rust-ui-test\\target\\debug\\deps\\rust_ui_test-158b451f6cadf32d.57m53vg1i8qf42vw.rcgu.o" "D:\\Projects\\Project-Test\\rust-ui-test\\target\\debug\\deps\\rust_ui_test-158b451f6cadf32d.gpt4vpsukvw7qn7.rcgu.o" "D:\\Projects\\Project-Test\\rust-ui-test\\target\\debug\\deps\\rust_ui_test-158b451f6cadf32d.kcy654qlb68m32.rcgu.o" "D:\\Projects\\Project-Test\\rust-ui-test\\target\\debug\\deps\\rust_ui_test-158b451f6cadf32d.3aesmvo6ri36sp96.rcgu.o" "-L" "D:\\Projects\\Project-Test\\rust-ui-test\\target\\debug\\deps" "-L" "D:\\Projects\\Project-Test\\rust-ui-test\\target\\debug\\build\\fltk-sys-801ec5ed56cc55d5\\out\\build" "-L" "D:\\Projects\\Project-Test\\rust-ui-test\\target\\debug\\build\\fltk-sys-801ec5ed56cc55d5\\out\\build\\Release" "-L" "D:\\Projects\\Project-Test\\rust-ui-test\\target\\debug\\build\\fltk-sys-801ec5ed56cc55d5\\out\\lib" "-L" "D:\\Projects\\Project-Test\\rust-ui-test\\target\\debug\\build\\fltk-sys-801ec5ed56cc55d5\\out\\lib64" "-L" "D:\\Projects\\Project-Test\\rust-ui-test\\target\\debug\\build\\fltk-sys-801ec5ed56cc55d5\\out\\lib\\Release" "-L" "D:\\Projects\\Project-Test\\rust-ui-test\\target\\debug\\build\\fltk-sys-801ec5ed56cc55d5\\out\\lib64\\Release" "-L" "D:\\Rust\\rustup_home\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "-Wl,-Bstatic" "D:\\Projects\\Project-Test\\rust-ui-test\\target\\debug\\deps\\libfltk-bafc1f02a1ee050a.rlib" "D:\\Projects\\Project-Test\\rust-ui-test\\target\\debug\\deps\\libttf_parser-6099efa460895059.rlib" "D:\\Projects\\Project-Test\\rust-ui-test\\target\\debug\\deps\\libcrossbeam_channel-1a87bdd8137c2f8b.rlib" "D:\\Projects\\Project-Test\\rust-ui-test\\target\\debug\\deps\\libcrossbeam_utils-2f9295815a767419.rlib" "D:\\Projects\\Project-Test\\rust-ui-test\\target\\debug\\deps\\libbitflags-8d49c2622a3eb446.rlib" "D:\\Projects\\Project-Test\\rust-ui-test\\target\\debug\\deps\\libfltk_sys-6a22e22e50d322ef.rlib" "D:\\Rust\\rustup_home\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libstd-3e14f4bf03bac47e.rlib" "D:\\Rust\\rustup_home\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libpanic_unwind-0902473778f72000.rlib" "D:\\Rust\\rustup_home\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libobject-1b52c822b74fcbd9.rlib" "D:\\Rust\\rustup_home\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libmemchr-7772d0b3d7a42076.rlib" "D:\\Rust\\rustup_home\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libaddr2line-c4d17796ffdb8a64.rlib" "D:\\Rust\\rustup_home\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libgimli-231ca6dff5410129.rlib" "D:\\Rust\\rustup_home\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_demangle-538065827e97d512.rlib" "D:\\Rust\\rustup_home\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libstd_detect-6cfc059822cc9268.rlib" "D:\\Rust\\rustup_home\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libhashbrown-f2d107dcc77a6f57.rlib" "D:\\Rust\\rustup_home\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_std_workspace_alloc-79a2ce77960c2d1e.rlib" "D:\\Rust\\rustup_home\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libminiz_oxide-533e07c20e1f803f.rlib" "D:\\Rust\\rustup_home\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libadler-13bc5119a1c7f0d1.rlib" "D:\\Rust\\rustup_home\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libunwind-da22f62c3fb90c0f.rlib" "D:\\Rust\\rustup_home\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcfg_if-2633f2be5fc303b2.rlib" "D:\\Rust\\rustup_home\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liblibc-a541fda2cb9d9bba.rlib" "D:\\Rust\\rustup_home\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liballoc-1ae8a2ec2312c402.rlib" "D:\\Rust\\rustup_home\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_std_workspace_core-7c0b778b66e448b5.rlib" "D:\\Rust\\rustup_home\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcore-f0b90fc8b3af3496.rlib" "D:\\Rust\\rustup_home\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcompiler_builtins-68a81561333edfd5.rlib" "-Wl,-Bdynamic" "-lws2_32" "-lcomctl32" "-lgdi32" "-loleaut32" "-lole32" "-luuid" "-lshell32" "-ladvapi32" "-lcomdlg32" "-lwinspool" "-luser32" "-lkernel32" "-lodbc32" "-lgdiplus" "-lsupc++" "-lgcc" "-lkernel32" "-ladvapi32" "-lbcrypt" "-lkernel32" "-lntdll" "-luserenv" "-lws2_32" "-lkernel32" "-lws2_32" "-lkernel32" "-lntdll" "-lkernel32" "-lgcc_eh" "-l:libpthread.a" "-lmsvcrt" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-luser32" "-lkernel32" "-Wl,--nxcompat" "-nostartfiles" "-L" "D:\\Rust\\rustup_home\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "-L" "D:\\Rust\\rustup_home\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\self-contained" "-o" "D:\\Projects\\Project-Test\\rust-ui-test\\target\\debug\\deps\\rust_ui_test-158b451f6cadf32d.exe" "-Wl,--gc-sections" "-no-pie" "-nodefaultlibs" "D:\\Rust\\rustup_home\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsend.o"
= note: ld: cannot find -lgdiplus: No such file or directory
ld: cannot find -lsupc++: No such file or directory

1
rustup update

更新一下,但没有效果,报错还是一样的,暂时先到这里。

记录一下。

2024年4月6日早晨八点。mouse-tracker的python项目我还是先用算法技巧来性能优化一下吧,不一定非要用rust重写。后面还会有很多用到rust的机会。