Buidling with wine

Hi, perhaps I'm doing something silly, I just want to try build a rust CLI tool in wine under linux. It never took off though. I'm getting a weird error implying a problem with certificate verification/revocation

wine64 cargo build gives

irrelevant wine debug

0024:err:ole:marshal_object couldn't get IPSFactory buffer for interface {00000131-0000-0000-c000-000000000046}
0024:err:ole:marshal_object couldn't get IPSFactory buffer for interface {6d5140c1-7436-11ce-8034-00aa006009fa}
0024:err:ole:StdMarshalImpl_MarshalInterface Failed to create ifstub, hres=0x80004002
0024:err:ole:CoMarshalInterface Failed to marshal the interface {6d5140c1-7436-11ce-8034-00aa006009fa}, 80004002
0024:err:ole:get_local_server_stream Failed: 80004002
0009:fixme:thread:SetThreadStackGuarantee (0x32fc50): stub

0009:fixme:bcrypt:BCryptOpenAlgorithmProvider algorithm L"DSA" not supported
0009:fixme:bcrypt:BCryptOpenAlgorithmProvider algorithm L"RC4" not supported
0009:fixme:bcrypt:BCryptOpenAlgorithmProvider algorithm L"3DES" not supported
0009:fixme:bcrypt:BCryptOpenAlgorithmProvider algorithm L"DH" not supported
0009:fixme:ntdll:NtLockFile I/O completion on lock not implemented yet
Updating crates.io index
0009:fixme:winhttp:request_set_option unimplemented option 109
0009:err:crypt:CRYPT_ImportSystemRootCertsToReg Failed to import system certs into registry, 00000057
warning: spurious network error (2 tries remaining): failed to send request: ; class=Os (2)
0009:fixme:winhttp:request_set_option unimplemented option 109
warning: spurious network error (1 tries remaining): failed to send request: ; class=Os (2)
0009:fixme:winhttp:request_set_option unimplemented option 109
error: failed to get async-std as a dependency of package mytool v0.1.0 (.../mytool/)

Caused by:
failed to fetch https://github.com/rust-lang/crates.io-index

Caused by:
failed to send request: ; class=Os (2)

The inspiration came from Using Rust in Wine as a sort of cross-compiler ยท GitHub . I used 64bit version though: wine64 msiexec /i Downloads/rust-nightly-x86_64-pc-windows-gnu.msi.

wine64 cargo --version --verbose gives

wine debug

0024:err:ole:marshal_object couldn't get IPSFactory buffer for interface {00000131-0000-0000-c000-000000000046}
0024:err:ole:marshal_object couldn't get IPSFactory buffer for interface {6d5140c1-7436-11ce-8034-00aa006009fa}
0024:err:ole:StdMarshalImpl_MarshalInterface Failed to create ifstub, hres=0x80004002
0024:err:ole:CoMarshalInterface Failed to marshal the interface {6d5140c1-7436-11ce-8034-00aa006009fa}, 80004002
0024:err:ole:get_local_server_stream Failed: 80004002
0009:fixme:thread:SetThreadStackGuarantee (0x32fc50): stub

cargo 1.52.0-nightly (bf5a5d5e5 2021-02-18)
release: 1.52.0
commit-hash: bf5a5d5e5d3ae842a63bfce6d070dfd438cf6070
commit-date: 2021-02-18

I thought this would have been an easy way to compile for windows on linux, but nope. It looks as though wine fails to import system certs, wild guess. It is thus probably not rust/cargo specific thing.

I also tried rustup-init.exe which failed to install a toolchain likely for the same reasons:

0029:err:crypt:CRYPT_ImportSystemRootCertsToReg Failed to import system certs into registry, 00000057
error: could not download file from 'https://static.rust-lang.org/dist/channel-rust-stable.toml.sha256' to 'C:\users\me.rustup\tmp\lbs165gw0zr76yg6_file'
error: caused by: failed to make network request
error: caused by: error sending request for url (https://static.rust-lang.org/dist/channel-rust-stable.toml.sha256): error trying to connect: OS Error -2146869244 (FormatMessageW() returned error 317) (os error -2146869244)
error: caused by: error trying to connect: OS Error -2146869244 (FormatMessageW() returned error 317) (os error -2146869244)
error: caused by: OS Error -2146869244 (FormatMessageW() returned error 317) (os error -2146869244)

OS Error -2146869244 is 0x800B010E, which according to some .net page should be:

The revocation process could not continue - the certificate(s) could not be checked.

Curiously, curl works. Downloads/curl-7.75.0-win64-mingw/bin/curl.exe https://static.rust-lang.org/dist/channel-rust-stable.toml.sha256 gives:

0024:err:ole:marshal_object couldn't get IPSFactory buffer for interface {00000131-0000-0000-c000-000000000046}
0024:err:ole:marshal_object couldn't get IPSFactory buffer for interface {6d5140c1-7436-11ce-8034-00aa006009fa}
0024:err:ole:StdMarshalImpl_MarshalInterface Failed to create ifstub, hres=0x80004002
0024:err:ole:CoMarshalInterface Failed to marshal the interface {6d5140c1-7436-11ce-8034-00aa006009fa}, 80004002
0024:err:ole:get_local_server_stream Failed: 80004002
3e45ff9e14774408be73b5ba6dba6137741b15c4ad838f613c43987ef1b9d650 channel-rust-stable.toml

wine64 --version

wine-4.0 (Debian 4.0-2)

Any hints? Thank you

For Linux to Windows cross compilation, after some short googling, this answer seems like a good starting point. Disclaimer: Never tried it myself.

Other answers, while technically correct, are more difficult than they need to be. There's no need to use rustc (in fact it's discouraged, just use cargo ), you only need rustup , cargo and your distribution's mingw-w64.

Add the target (you can also change this for whatever target you're cross compiling for):

rustup target add x86_64-pc-windows-gnu
rustup toolchain install stable-x86_64-pc-windows-gnu

You can build your crate easily with:

cargo build --target x86_64-pc-windows-gnu

No need for messing around with ~/.cargo/config or anything else.

EDIT: Just wanted to add that while you can use the above it can also sometimes be a headache. I wanted to add that the rust tools team also maintains a project called cross: https://github.com/rust-embedded/cross This might be another solution that you want to look into

I think this would be a fine path if I didn't run into all sorts of C compilation problems. Unfortunately, many rust crates depend on C/C++ code and cross-compiling these is not always trivial.

I am trying to pursue this path as well, but I think it would be good to focus this thread on wine. The cross compilation as you suggest actually works after installing the required mingw packages...

Perhaps you can try to get cargo --offline to work first (possibly by copying the necessary files from a Linux build) and then work on fixing networking.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.