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

Issues cross-compiling from Linux to Windows #13

Open
YaLTeR opened this issue Jun 15, 2020 · 1 comment
Open

Issues cross-compiling from Linux to Windows #13

YaLTeR opened this issue Jun 15, 2020 · 1 comment

Comments

@YaLTeR
Copy link

YaLTeR commented Jun 15, 2020

I am cross-compiling from x86-64-unknown-linux-gnu to i686-pc-windows-gnu. Here are some issues I encountered:

  • /home/yalter/.cargo/registry/src/github.com-1ecc6299db9ec823/rust_hawktracer_sys-0.4.2/hawktracer/lib/tcp_server.cpp:96:10: fatal error: WinSock2.h: No such file or directory
       96 | #include <WinSock2.h>
          |          ^~~~~~~~~~~~
    
    /home/yalter/.cargo/registry/src/github.com-1ecc6299db9ec823/rust_hawktracer_sys-0.4.2/hawktracer/lib/platform/windows/memory_usage.c:4:10: fatal error: Windows.h: No such file or directory
        4 | #include <Windows.h>
          |          ^~~~~~~~~~~
    
    /home/yalter/.cargo/registry/src/github.com-1ecc6299db9ec823/rust_hawktracer_sys-0.4.2/hawktracer/lib/platform/windows/memory_usage.c:5:10: fatal error: Psapi.h: No such file or directory
        5 | #include <Psapi.h>
          |          ^~~~~~~~~
    
    Fixed by making those includes all-lowercase.
  • cargo:rustc-link-search=all=/home/yalter/source/rs/bxt-rs/target/i686-pc-windows-gnu/debug/build/rust_hawktracer_sys-c9794263c9fe5873/out/build/lib/Debug
    
    When using MinGW there's no additional Debug/Release/RelWithDebInfo folder in the end. Fixed by commenting out a line in build.rs.
  • A lot of C++ linking errors. Fixed by copying the println!("cargo:rustc-link-lib=dylib=stdc++"); line into the Windows branch as well. Although that made the built .dll require libstdc++-6.dll and a few other MinGW dlls; I couldn't change the line to say static because it couldn't find the static libstdc++ for some reason.

With those hack fixes in place, everything seemed to work fine.

I suspect these issues are specific to windows-gnu in general and not to just cross-compiling.

@AlexEne
Copy link
Owner

AlexEne commented Jun 15, 2020

I didn't try this configuration, as I use the msvc windows build.
Would you mind opening a PR with your changes? The CI passes do test windows default config as well as linux, so if it passes, I can merge it. Thinking about it, windows build assumes msvc when build.rs is executed.

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

2 participants