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

build error #28

Open
Archieeeeee opened this issue Dec 16, 2021 · 2 comments
Open

build error #28

Archieeeeee opened this issue Dec 16, 2021 · 2 comments

Comments

@Archieeeeee
Copy link

Archieeeeee commented Dec 16, 2021

error: linking with `link.exe` failed: exit code: 1181
  |
  = note: "d:\\Program Files\\Microsoft Visual Studio\\2022\\Preview\\VC\\Tools\\MSVC\\14.31.30818\\bin\\HostX64\\x64\\link.exe" "/NOLOGO" ... ...
= note: Non-UTF-8 output: LINK : fatal error LNK1181: \xce\xde\xb7\xa8\xb4\xf2\xbf\xaa\xca\xe4\xc8\xeb\xce\xc4\xbc\xfe\xa1\xb0Packet.lib\xa1\xb1\r\n

sorry , I find this by searching maybe that is the cause, so I have to provide pcap library?

You must have WinPcap or npcap installed (tested with version WinPcap 4.1.3) (If using npcap, make sure to install with the "Install Npcap in WinPcap API-compatible Mode")
You must place Packet.lib from the WinPcap Developers pack in a directory named lib, in the root of this repository. Alternatively, you can use any of the locations listed in the %LIB%/$Env:LIB environment variables. For the 64 bit toolchain it is in WpdPack/Lib/x64/Packet.lib, for the 32 bit toolchain, it is in WpdPack/Lib/Packet.lib.
@bparli
Copy link
Owner

bparli commented Mar 20, 2022

Hi @Archieeeeee - this library will likely not work on Windows as the underlying library (pnet) doesn't either last I knew.

@TDiblik
Copy link

TDiblik commented Jul 13, 2023

Hey, just a heads up, you can (now) run this on Windows. All you have to do is:

  • Follow pnet official setup README (TLDR; install WinPcap ; download WinPap Developer pack => build it => copy Packet.lib to the root of your project (next to your Cargo.toml file)
  • Setup build.rs where you set manifest for your app, to always require admin privileges on startup, like this:

Cargo.toml

[target.'cfg(windows)'.build-dependencies]
winres = "0.1.12" # or whatever is the latest version

build.rs

fn main() {
    // Tell windows that executable requires admin privileges.
    #[cfg(target_os = "windows")]
    {
        let mut res = winres::WindowsResource::new();
        res.set_manifest(
            r#"
        <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
        <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
            <security>
                <requestedPrivileges>
                    <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
                </requestedPrivileges>
            </security>
        </trustInfo>
        </assembly>
        "#,
        );
        if let Err(error) = res.compile() {
            eprint!("{}", error);
            std::process::exit(1);
        }
    }
}

PS: Make sure that you're running cargo run from terminal with escalated (admin) privileges

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