Cross compilation from Linux? #41
Comments
There issue is a build script needs to be run on the host system (linux), but it contains Windows specific code. It can be fixed with these changes:
See this branch with above changes that make compilation work on linux: https://github.com/JasperDeSutter/windows-app-rs/tree/linux-support |
This is super helpful, I appreciate it a lot. I cloned that branch of your repo. I'm still running into issues running the executable, but here's what I tried: GNU toolchainNote that I needed to update to the nightly (i.e. $ cargo build --target x86_64-pc-windows-gnu
...
= note: /usr/bin/x86_64-w64-mingw32-ld: cannot find -lMicrosoft.WindowsAppRuntime.Bootstrap
collect2: error: ld returned 1 exit status I do note that I have the right file showing up in the folder, but I guess I just can't link to it?
So I added the location manually to RUSTFLAGS (which is a bit hacky, so probably not the final solution): Now this builds! $ cargo build --target x86_64-pc-windows-gnu
...
Finished dev [unoptimized + debuginfo] target(s) in 41.77s This is great, but the final .exe isn't runnable yet from WSL: $ ./target/x86_64-pc-windows-gnu/debug/sample_xamlapp.exe
Error: Error { code: 0x80070491, message: There was no match for the specified key in the index.
} and if I copy it out into my Windows installation and try to run it, I get: Note that I have installed the Windows App Runtime as indicated on the README. I tried statically linking, by adding this to my
but no cigar. MSVC toolchainI was able to compile with the MSVC toolchain, after installing $ cargo build --target x86_64-pc-windows-msvc
...
Finished dev [unoptimized + debuginfo] target(s) in 41.41s But this fails for the above reasons as well. I kind of get the sense that these are basic issues, but unfortunately I'm unable to figure it out, so if anyone has an idea I would appreciate the help! |
Ok, got it to run. The above issue was solved after using the steps here: microsoft/WindowsAppSDK#1953; in particular, I:
And the expected app ran both in the WSL environment and in Windows, as expected. Ideas for improving this process:
I'm happy to do any of those (except 4) if you'd prefer a pull request. |
Hey all, sorry I didn't reply sooner--lots of things moving around on my side. The README is pointing to a link that I thought was going to continue getting updates but I see I was wrong. It should be pointing to the latest 1.0.3 bits as you painfully discovered. I'll get the crate updated right now. |
Thank you! |
I know this project is currently experimental, and this isn't a priority, but I figured I'd document in case someone else runs into this.
I'm trying to compile the example in the README from WSL using Linux cross compilation, which includes installing MinGW:
This seems to almost work (because
windows-rs
supports cross compilation, it seems) but fails when the linker tries to find the app runtime:I'm really not sure how this could be solved, but it would be nice to have the workflow in WSL more clear. Thanks!
The text was updated successfully, but these errors were encountered: