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

Can it build on Linux to windows #246

Open
TomatoMr opened this issue Aug 7, 2022 · 10 comments
Open

Can it build on Linux to windows #246

TomatoMr opened this issue Aug 7, 2022 · 10 comments
Labels

Comments

@TomatoMr
Copy link

TomatoMr commented Aug 7, 2022

I want to build on Linux to Windows, can it supports?

@Wojtek242
Copy link
Collaborator

Yes, please see the README for instructions

@Wojtek242
Copy link
Collaborator

Oh sorry, misunderstood your question. I thought you asked if it builds on Windows.

Building from Linux to Windows should work since we support Windows builds, but we don't have it documented.

@TomatoMr
Copy link
Author

😁Thank you very much for your reply. I would be very grateful if there are documents or construction guidelines.

@TomatoMr
Copy link
Author

I used the build tool: cargo-xwin , and tried to run:

cargo xwin build --target x86_64-pc-windows-msvc

then, I got the failed info:

  = note: lld-link: error: could not open 'wpcap.lib': No such file or directory
          lld-link: error: could not open 'pcap.lib': No such file or directory

image

I have downloaded the SDK of WinPcap and copied wpcap.lib and packet.lib in the x64 directory to Linux. But I can't find pcap.lib

@Wojtek242
Copy link
Collaborator

I'm no expert on cross-compiling so I can't help you here. However, I'll reopen the issue so that somebody else perhaps will see this and answer.

@Wojtek242 Wojtek242 reopened this Aug 14, 2022
@Wojtek242 Wojtek242 added the docs label Aug 14, 2022
@TomatoMr
Copy link
Author

tks🌹

@Stargateur
Copy link
Contributor

Stargateur commented Aug 18, 2022

have you try use LIB env variable to pin point the location of wpcap.lib ? also try to just put the file at the root of the project. Should work.

@TomatoMr
Copy link
Author

have you try use LIB env variable to pin point the location of wpcap.lib ? also try to just put the file at the root of the project. Should work.

Yes, I tried it, it didn't work. I also tried to copy and rename wpcap.lib to pcap.lib, but it still failed with the error: lld-link: error: could not open 'pcap.lib': No such file or directory. I can't find pcap.lib.

@robs-zeynet
Copy link
Contributor

robs-zeynet commented Dec 15, 2022

You might try building with a build.rs (which puts the build information into the build process) instead of the manual environmental variable. The following build.rs works for me on a "built for windows, on windows" build which I haven't tried from Linux, but should be a reasonable starting point. It assumes the same directory structure as what comes out of the npcap dev libs, e.g., that if you want a x64 bit build, you want to use the "lib/x64" subdir.

robsh@LAPTOP-O7RS71IJ MINGW64 ~/git/myproj (main)
$ find lib/
lib/
lib/x64
lib/x64/Packet.lib
lib/x64/wpcap.lib

robsh@LAPTOP-O7RS71IJ MINGW64 ~/git/myproj (main)
$ ls build.rs
build.rs

$ cat build.rs
use std::env;
use std::path::Path;

fn main() {
    let dir = env::var("CARGO_MANIFEST_DIR").unwrap();
    println!(
        "cargo:rustc-link-search=native={}",
        Path::new(&dir).join("lib/x64").display()
    );
}

@TomatoMr
Copy link
Author

You might try building with a build.rs (which puts the build information into the build process) instead of the manual environmental variable. The following build.rs works for me on a "built for windows, on windows" build which I haven't tried from Linux, but should be a reasonable starting point. It assumes the same directory structure as what comes out of the npcap dev libs, e.g., that if you want a x64 bit build, you want to use the "lib/x64" subdir.

robsh@LAPTOP-O7RS71IJ MINGW64 ~/git/myproj (main)
$ find lib/
lib/
lib/x64
lib/x64/Packet.lib
lib/x64/wpcap.lib

robsh@LAPTOP-O7RS71IJ MINGW64 ~/git/myproj (main)
$ ls build.rs
build.rs

$ cat build.rs
use std::env;
use std::path::Path;

fn main() {
    let dir = env::var("CARGO_MANIFEST_DIR").unwrap();
    println!(
        "cargo:rustc-link-search=native={}",
        Path::new(&dir).join("lib/x64").display()
    );
}

@robs-zeynet thank you, i had tried it, but it not worked

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

No branches or pull requests

4 participants