rust-pcap / pcap

Rust language pcap library
Apache License 2.0
594 stars 138 forks source link

link failure #327

Closed sajis997 closed 4 months ago

sajis997 commented 4 months ago

I am trying to add the crate (pcap = "1.2.0") to my project in windows 11 platform with rust 1.76.0 installed. While building I am getting the following link error:

LINK : fatal error LNK1181: cannot open input file 'wpcap.lib'

Wojtek242 commented 4 months ago

Do you have Npcap installed as per the instructions here: https://github.com/rust-pcap/pcap#windows?

sajis997 commented 4 months ago

Npcap is installed, sdk extracted and path to the extraction is also added to the user's path environment variable. I could echo the path on the command line. But while compiling and linking with the crate , the link error remains.

sajis997 commented 4 months ago

image

Only one option is checked as above, do we need to check more ? which one ?

m-vz commented 4 months ago

@sajis997 The guide says to add the path to the LIB variable, not to PATH...

However, I see the same linker error when trying to build my project on Windows. My LIB variable is set up as follows:

Capture

Stargateur commented 4 months ago

if you use windows variable environment you need to restart your shell window. if you start going crazy, you can try copy all lib file directly in your project root maybe it will work.

m-vz commented 4 months ago

I found out how to set the ENV variables in a build script, seems simpler... I'm still unsure though about what the difference between the LIB and the LIBPCAP_LIBDIR variables is. They're both mentioned in the readme. Do they both point to the same location?

Wojtek242 commented 4 months ago

LIB is a Windows environment variable. LIBPCAP_LIBDIR is an environment variable specific to this crate. If you have LIB set correctly, you should not need LIBPCAP_LIBDIR.

As this is not a bug in the crate, but a build issue that appears resolved, I am closing the issue.

If this is still an issue for you, please re-open, but be aware that I do not own a Windows machine so I cannot help you.