fastping-rs icon indicating copy to clipboard operation
fastping-rs copied to clipboard

build error

Open Archieeeeee opened this issue 4 years ago • 2 comments

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.

Archieeeeee avatar Dec 16 '21 02:12 Archieeeeee

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

bparli avatar Mar 20 '22 02:03 bparli

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

TDiblik avatar Jul 13 '23 23:07 TDiblik