Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cross-compiling from Linux results in: "No windir environment variable found #143

Closed
Susurrus opened this issue May 16, 2020 · 3 comments
Closed

Comments

@Susurrus
Copy link

I'm on x86_64 Manjaro running Rust trying to build this library. It'd be helpful to know what targets (as defined by Rust) are supported. I'm trying to compile for x86_64-pc-windows-gnu (x86_64-pc-windows-msvc has the same error):

$ cargo build --features win_rt --target x86_64-pc-windows-gnu
   Compiling serialport v3.3.1-alpha.0 (/home/susurrus/Projects/serialport-rs)
error: proc macro panicked
  --> src/windows/winrt.rs:12:1
   |
12 | / import!(
13 | |     dependencies
14 | |     os
15 | |     modules
...  |
18 | |         "windows.storage.streams"
19 | | );
   | |__^
   |
   = help: message: No `windir` environment variable found

error: aborting due to previous error

error: could not compile `serialport`.

To learn more, run the command again with --verbose.
@robmikh
Copy link
Member

robmikh commented May 16, 2020

In order to generate the projection, the metadata files that define the WinRT API surface are required. Normally on a Windows installation, you can find these metadata files in a directory like C:\Windows\System32\WinMetadata. Since Windows isn't necessarily always installed to the C drive, the %windir% environment variable is used. You can also get the metadata through the Windows SDK or packaged inside of 3rd party components like the Win2D nuget package (although that metadata will only contain the metadata for the Win2D API). Currently the metadata is taken from the operating system and recently from nuget (see #93).

For your situation, I'm not sure what's the best way forward, as you also need other libs. In order for the projection to work, it needs to be able to call into RoGetActivationFactory and other functions found in the onecore lib found in the Windows SDK.

If you can define a windir environment variable that will point to the correct metadata and provide the required libs, then you might be able to get this to work. No promises though, I don't think any of us have tried this on any of the Linux distros yet.

At the moment only *-windows-msvc is supported, (see #142).

@kennykerr
Copy link
Collaborator

The code itself is portable. We have had versions of WinRT support written in C++ that run on Linux. But as Robert points out, metadata is required to describe available APIs and certain PAL functions are required for loading libraries. So we could support this in future, but it is not an immediate goal. If this is something that folks would like to do, feel free to chime in on this issue and let us know.

@Susurrus
Copy link
Author

Okay, thanks for clarifying that. Would it be possible to add that info to the README? Definitely wasn't clear that this only supports building on Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants