bparli / fastping-rs

ICMP ping library in Rust inspired by go-fastping and AnyEvent::FastPing Perl module
MIT License
78 stars 12 forks source link

build error #28

Open Archieeeeee opened 2 years ago

Archieeeeee commented 2 years ago
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 commented 2 years ago

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

TDiblik commented 1 year ago

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

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