A port of robmikh/Minesweeper using windows-rs.
Running this sample requires at least Windows build 1803 (v10.0.17134.0). To compile and run (after setting up), use:
cargo run --release
A port of robmikh/Minesweeper using windows-rs.
License: MIT License
A port of robmikh/Minesweeper using windows-rs.
Running this sample requires at least Windows build 1803 (v10.0.17134.0). To compile and run (after setting up), use:
cargo run --release
Cargo.lock should be taken out of version control, perhaps?
OS version: Windows 10 Professional 21H1 (19043.1165)
Rust version: 1.53.0
The error info is as below.
ld: cannot find -ld2d1
ld: cannot find -lCoreMessaging
ld: cannot find -lonecoreuap
How should I fix this?
Hi @robmikh, @kennykerr suggested that I use minesweeper-rs as an example microsoft/windows-rs#384 after I asked about ClickOnce deployment of a WinRT/Rust example microsoft/windows-rs#372. I am interested in trying out ClickOnce, as well as publishing to winget and the Microsoft Store. For all of the options, it looks like I'll need a valid code signing certificate, so I ordered one for my Taggart Software LLC for $84. Unfortunately, it looks like it may be up to a week before I can get it validated by Sectigo due to the wrong phone number being listed at Dun & Bradstreet.
My goal is just to try out the various options for publishing a WinRT/Rust app and share that knowledge. I'll probably create a fork in either https://github.com/ctaggart or https://github.com/taggartsoftware in order to figure out how to do it. I'm creating this issue in case this is something you wish to collaborate. A png program icon would be super helpful. ๐
For the record, this first appeared when I used bindings with my own project even after I only copied some code instead of just using the entire project. This is not an issue when the rustfmt.toml is in the bindings project folder, it only fails to build in a project that builds an exe and uses bindings, like Minesweeper and my own project.
As to why it confuses it with some other config file, I'm too fresh to Rust, still. I don't even know where, in Rust, in CLion in your code, or even in my code, this issue really lays. And CLion uses an additional Rust and Toml plugin, so...
Removing the rustfmt.toml file solved the exit code 101 issue:
Compiling bindings v0.1.0 (D:\_ Toy Maker\enamorf_showcase\enamorf_application\bindings)
error: failed to run custom build command for `bindings v0.1.0 (D:\_ ToyMaker\enamorf_showcase\enamorf_application\bindings)`
Caused by:
process didn't exit successfully: `D:\_ Toy Maker\enamorf_showcase\enamorf_application\target\release\build\bindings-4fc5abab444cf7ad\build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-changed=C:\Windows\System32\winmetadata\Windows.AI.winmd
cargo:rerun-if-changed=C:\Windows\System32\winmetadata\Windows.ApplicationModel.winmd
cargo:rerun-if-changed=C:\Windows\System32\winmetadata\Windows.Data.winmd
cargo:rerun-if-changed=C:\Windows\System32\winmetadata\Windows.Devices.winmd
cargo:rerun-if-changed=C:\Windows\System32\winmetadata\Windows.Foundation.winmd
cargo:rerun-if-changed=C:\Windows\System32\winmetadata\Windows.Gaming.winmd
cargo:rerun-if-changed=C:\Windows\System32\winmetadata\Windows.Globalization.winmd
cargo:rerun-if-changed=C:\Windows\System32\winmetadata\Windows.Graphics.winmd
cargo:rerun-if-changed=C:\Windows\System32\winmetadata\Windows.Management.winmd
cargo:rerun-if-changed=C:\Windows\System32\winmetadata\Windows.Media.winmd
cargo:rerun-if-changed=C:\Windows\System32\winmetadata\Windows.Networking.winmd
cargo:rerun-if-changed=C:\Windows\System32\winmetadata\Windows.Perception.winmd
cargo:rerun-if-changed=C:\Windows\System32\winmetadata\Windows.Security.winmd
cargo:rerun-if-changed=C:\Windows\System32\winmetadata\Windows.Services.winmd
cargo:rerun-if-changed=C:\Windows\System32\winmetadata\Windows.Storage.winmd
cargo:rerun-if-changed=C:\Windows\System32\winmetadata\Windows.System.winmd
cargo:rerun-if-changed=C:\Windows\System32\winmetadata\Windows.UI.Xaml.winmd
cargo:rerun-if-changed=C:\Windows\System32\winmetadata\Windows.UI.winmd
cargo:rerun-if-changed=C:\Windows\System32\winmetadata\Windows.Web.winmd
--- stderr
Warning: Unknown configuration option `fn_params_layout`
Warning: Unknown configuration option `struct`
Error: Decoding config file failed:
invalid type: string "Max", expected struct WidthHeuristics for key `width_heuristics`
Please check your config file.
Warning: Unknown configuration option `fn_params_layout`
Warning: Unknown configuration option `struct`
Error: Decoding config file failed:
invalid type: string "Max", expected struct WidthHeuristics for key `width_heuristics`
Please check your config file.
thread 'main' panicked at 'Could not successfully build', bindings\build.rs:1:1
stack backtrace:
0: backtrace::backtrace::trace_unsynchronized
at C:\Users\VssAdministrator\.cargo\registry\src\github.com-1ecc6299db9ec823\backtrace-0.3.46\src\backtrace\mod.rs:66
1: std::sys_common::backtrace::_print_fmt
at /rustc/5c1f21c3b82297671ad3ae1e8c942d2ca92e84f2\/src\libstd\sys_common\backtrace.rs:78
2: std::sys_common::backtrace::_print::{{impl}}::fmt
at /rustc/5c1f21c3b82297671ad3ae1e8c942d2ca92e84f2\/src\libstd\sys_common\backtrace.rs:59
3: core::fmt::write
at /rustc/5c1f21c3b82297671ad3ae1e8c942d2ca92e84f2\/src\libcore\fmt\mod.rs:1076
4: std::io::Write::write_fmt<std::sys::windows::stdio::Stderr>
at /rustc/5c1f21c3b82297671ad3ae1e8c942d2ca92e84f2\/src\libstd\io\mod.rs:1537
5: std::sys_common::backtrace::_print
at /rustc/5c1f21c3b82297671ad3ae1e8c942d2ca92e84f2\/src\libstd\sys_common\backtrace.rs:62
6: std::sys_common::backtrace::print
at /rustc/5c1f21c3b82297671ad3ae1e8c942d2ca92e84f2\/src\libstd\sys_common\backtrace.rs:49
7: std::panicking::default_hook::{{closure}}
at /rustc/5c1f21c3b82297671ad3ae1e8c942d2ca92e84f2\/src\libstd\panicking.rs:198
8: std::panicking::default_hook
at /rustc/5c1f21c3b82297671ad3ae1e8c942d2ca92e84f2\/src\libstd\panicking.rs:218
9: std::panicking::rust_panic_with_hook
at /rustc/5c1f21c3b82297671ad3ae1e8c942d2ca92e84f2\/src\libstd\panicking.rs:486
10: std::panicking::begin_panic
11: alloc::alloc::box_free
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Process finished with exit code 101
I can spot a "Error: Decoding config file failed:" twice. Seems there is nothing behind the colon even when it should!? Also note that my rustfm.toml file is actually longer, so some unknown config options aren't in that error. Maybe it actually reading false memory to begin with, not just the file path. That's my full file:
unstable_features = true
brace_style = "AlwaysNextLine"
control_brace_style = "AlwaysNextLine"
imports_layout = "Horizontal"
fn_params_layout = "Compressed"
where_single_line = true
width_heuristics = "Max"
struct = "Visual"
max_width = 200
Anyways... side info. I'm using CLion, Rust 1.45.0, and had Rust 1.44.1 previously, same error code 101, though.
Have the tiles shrunk in a recent update?
I've attempted to run via cargo run --release
this however I get this error:
error: linking with `cc` failed: exit code: 1
|
= note: "cc" "-m64" "-arch" "x86_64" "-L" "./.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "./minesweeper-rs/target/release/build/bindings-45b5e74a322a3fcf/build_script_build-45b5e74a322a3fcf.build_script_build.d12wqb6e-cgu.0.rcgu.o" "./minesweeper-rs/target/release/build/bindings-45b5e74a322a3fcf/build_script_build-45b5e74a322a3fcf.build_script_build.d12wqb6e-cgu.1.rcgu.o" "./minesweeper-rs/target/release/build/bindings-45b5e74a322a3fcf/build_script_build-45b5e74a322a3fcf.build_script_build.d12wqb6e-cgu.10.rcgu.o" "./minesweeper-rs/target/release/build/bindings-45b5e74a322a3fcf/build_script_build-45b5e74a322a3fcf.build_script_build.d12wqb6e-cgu.11.rcgu.o" "./minesweeper-rs/target/release/build/bindings-45b5e74a322a3fcf/build_script_build-45b5e74a322a3fcf.build_script_build.d12wqb6e-cgu.12.rcgu.o" "./minesweeper-rs/target/release/build/bindings-45b5e74a322a3fcf/build_script_build-45b5e74a322a3fcf.build_script_build.d12wqb6e-cgu.13.rcgu.o" "./minesweeper-rs/target/release/build/bindings-45b5e74a322a3fcf/build_script_build-45b5e74a322a3fcf.build_script_build.d12wqb6e-cgu.14.rcgu.o" "./minesweeper-rs/target/release/build/bindings-45b5e74a322a3fcf/build_script_build-45b5e74a322a3fcf.build_script_build.d12wqb6e-cgu.15.rcgu.o" "./minesweeper-rs/target/release/build/bindings-45b5e74a322a3fcf/build_script_build-45b5e74a322a3fcf.build_script_build.d12wqb6e-cgu.2.rcgu.o" "./minesweeper-rs/target/release/build/bindings-45b5e74a322a3fcf/build_script_build-45b5e74a322a3fcf.build_script_build.d12wqb6e-cgu.3.rcgu.o" "./minesweeper-rs/target/release/build/bindings-45b5e74a322a3fcf/build_script_build-45b5e74a322a3fcf.build_script_build.d12wqb6e-cgu.4.rcgu.o" "./minesweeper-rs/target/release/build/bindings-45b5e74a322a3fcf/build_script_build-45b5e74a322a3fcf.build_script_build.d12wqb6e-cgu.5.rcgu.o" "./minesweeper-rs/target/release/build/bindings-45b5e74a322a3fcf/build_script_build-45b5e74a322a3fcf.build_script_build.d12wqb6e-cgu.6.rcgu.o" "./minesweeper-rs/target/release/build/bindings-45b5e74a322a3fcf/build_script_build-45b5e74a322a3fcf.build_script_build.d12wqb6e-cgu.7.rcgu.o" "./minesweeper-rs/target/release/build/bindings-45b5e74a322a3fcf/build_script_build-45b5e74a322a3fcf.build_script_build.d12wqb6e-cgu.8.rcgu.o" "./minesweeper-rs/target/release/build/bindings-45b5e74a322a3fcf/build_script_build-45b5e74a322a3fcf.build_script_build.d12wqb6e-cgu.9.rcgu.o" "-o" "./minesweeper-rs/target/release/build/bindings-45b5e74a322a3fcf/build_script_build-45b5e74a322a3fcf" "./minesweeper-rs/target/release/build/bindings-45b5e74a322a3fcf/build_script_build-45b5e74a322a3fcf.11sqhe0gv7c5wce.rcgu.o" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "./minesweeper-rs/target/release/deps" "-L" "./.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "./minesweeper-rs/target/release/deps/libwindows-e290cbb7c425a5b7.rlib" "./minesweeper-rs/target/release/deps/libconst_sha1-b328c65c105a66f0.rlib" "./minesweeper-rs/target/release/deps/libwindows_gen-a3eb1ad7b28f0c8b.rlib" "./minesweeper-rs/target/release/deps/librayon-48b43214135c0ea6.rlib" "./minesweeper-rs/target/release/deps/librayon_core-cc4456437fc0544a.rlib" "./minesweeper-rs/target/release/deps/libnum_cpus-68cd34d7d0638442.rlib" "./minesweeper-rs/target/release/deps/liblibc-b938c011a57fb6c0.rlib" "./minesweeper-rs/target/release/deps/libcrossbeam_deque-6a319676fa35cf2d.rlib" "./minesweeper-rs/target/release/deps/libcrossbeam_epoch-8245a9fc1d08c456.rlib" "./minesweeper-rs/target/release/deps/libmemoffset-2c7064c837bfb65d.rlib" "./minesweeper-rs/target/release/deps/libscopeguard-fb3fcdf14a4f4ea8.rlib" "./minesweeper-rs/target/release/deps/libcrossbeam_channel-094e512a772bea27.rlib" "./minesweeper-rs/target/release/deps/libcrossbeam_utils-46ebdc4138070899.rlib" "./minesweeper-rs/target/release/deps/liblazy_static-5770113e35436fa3.rlib" "./minesweeper-rs/target/release/deps/libcfg_if-7c76d056c23fe077.rlib" "./minesweeper-rs/target/release/deps/libeither-06fb22c1d1d80ba1.rlib" "./minesweeper-rs/target/release/deps/libsquote-58c8a2ff68843455.rlib" "./minesweeper-rs/target/release/deps/libwindows_winmd-7edfa1bcd63ec68e.rlib" "./minesweeper-rs/target/release/deps/libserde_json-59d627436898e2a1.rlib" "./minesweeper-rs/target/release/deps/libryu-1dda1a32b60a1b67.rlib" "./minesweeper-rs/target/release/deps/libitoa-8f09c5e740ff5cd2.rlib" "./minesweeper-rs/target/release/deps/libserde-ba17a0805c2646d0.rlib" "./.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd-518979da66993550.rlib" "./.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-f52081aedccc205f.rlib" "./.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libobject-bad1c02788187328.rlib" "./.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libaddr2line-6375d8dbf53aee9d.rlib" "./.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libgimli-0ea8539778b0c0ab.rlib" "./.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_demangle-64f30c6d69babb18.rlib" "./.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libhashbrown-e27428d997fd2532.rlib" "./.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_alloc-f02467a76e5a8054.rlib" "./.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libunwind-9536efad7116d828.rlib" "./.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcfg_if-5ca171f6ec11d7a5.rlib" "./.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liblibc-14b621861b38e51f.rlib" "./.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc-38f4a0c206512fa5.rlib" "./.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_core-99bca6ace58141c5.rlib" "./.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcore-72a66f4c97a4c0c8.rlib" "./.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-e7cd9f0beed2fc0f.rlib" "-loleaut32" "-lkernel32" "-loleaut32" "-lkernel32" "-lole32" "-lkernel32" "-lkernel32" "-lkernel32" "-loleaut32" "-lSystem" "-lresolv" "-lc" "-lm"
= note: ld: library not found for -loleaut32
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: aborting due to previous error
error: could not compile `bindings`
Caused by:
process didn't exit successfully: `rustc --crate-name build_script_build --edition=2018 bindings/build.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debug-assertions=off -C metadata=45b5e74a322a3fcf -C extra-filename=-45b5e74a322a3fcf --out-dir ./minesweeper-rs/target/release/build/bindings-45b5e74a322a3fcf -L dependency=./minesweeper-rs/target/release/deps --extern windows=./minesweeper-rs/target/release/deps/libwindows-e290cbb7c425a5b7.rlib` (exit code: 1)
Cargo is version cargo 1.49.0 (d00d64df9 2020-12-05).
Please let me know if you need any other environment info, I'm not familiar with rust.
As I am trying building with target thumbv7a-uwp-windows-msvc
, compilation failed:
error[E0570]: The ABI `"stdcall"` is not supported for the current target
--> C:\Users\bdbai\.cargo\registry\src\github.com-1ecc6299db9ec823\com-0.2.0\src\interfaces\iclass_factory.rs:12:1
|
12 | #[com_interface("00000001-0000-0000-c000-000000000046")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0570]: The ABI `"stdcall"` is not supported for the current target
--> C:\Users\bdbai\.cargo\registry\src\github.com-1ecc6299db9ec823\com-0.2.0\src\interfaces\iunknown.rs:8:1
|
8 | #[com_interface("00000000-0000-0000-C000-000000000046")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
It looked like a problem with com-rs
and had been reported (see microsoft/com-rs#92 (comment)). Then I checked out the commit before using com-rs at 946a74, a similar error came out:
error[E0570]: The ABI `"stdcall"` is not supported for the current target
--> src\uwp\interop.rs:2:1
2 | / extern "stdcall" {
3 | | fn RoInitialize(init_type: RoInitType) -> winrt::ErrorCode;
4 | | }
| |_^
Fixed by changing stdcall
to system
. After that, I managed to package and deployed it to a ARM device, a panic immediately occurred without previous stack trace.
(A screenshot of the call stack recovered from a minidump)
Further investigation is required to make it run on an ARM device.
Compiling winmd_macros v0.1.0 (https://github.com/microsoft/winrt-rs#837e0cb1)
error[E0432]: unresolved import proc_macro
--> C:\Users\Ra.cargo\git\checkouts\winrt-rs-5b24704ba4b09dbb\837e0cb\crates\winmd\macros\src\lib.rs:1:5
|
1 | use proc_macro::TokenStream;
| ^^^^^^^^^^ help: a similar path exists: syn::proc_macro
error: aborting due to previous error
For more information about this error, try rustc --explain E0432
.
error: could not compile winmd_macros
.
warning: build failed, waiting for other jobs to finish...
error: build failed
PS C:\Users\Ra\minesweeper-rs>
Using Jake Shadle's Dockerfile I am capable of cross-compiling to windows your minesweeper entirely from debian bullseye.
Here's an article discussing the process involved:
https://jake-shadle.github.io/xwin/
I've summarized the steps below for a successful cross-compile for you using windows crate v0.19.0.
Here's the Dockerfile
https://gist.github.com/omac777/1f231073f4b313e20376c386f48c6dc3
To build the docker image:
sudo service docker restart
sudo service docker status
docker image ls
docker rmi -f 2089c03a47ca
docker build --network host -t playxwinimg .
docker container ls --all
Please change the following windows crate dependencies to version 0.19.0.
grep -n -H "0.19.0" Cargo.toml
Cargo.toml:8:windows = "0.19.0"
grep -n -H "0.19.0" bindings/Cargo.toml
bindings/Cargo.toml:7:windows = "0.19.0"
bindings/Cargo.toml:10:windows = "0.19.0"
Then to build your minesweeper:
git clone https://github.com/robmikh/minesweeper-rs.git
sudo chmod -R 777 minesweeper-rs
docker run --rm --network host -v /home/loongson/tryredox/playxwin/minesweeper-rs:/srv/minesweeper-rs -i -t playxwinimg:latest /bin/bash
cd /srv/minesweeper-rs
cargo build --target x86_64-pc-windows-msvc --release
Thank you in advance.
It's much easier to show what a repo is about by putting an image in the readme. It would also be good to mention that you just need to install Rust and run cargo run --release
to run the app.
//static WINDOW_CLASS_NAME: &HSTRING = h!("minesweeper-rs.Window");
const WINDOW_CLASS_NAME: PCWSTR = w!("minesweeper-rs.Window");
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.