-
Notifications
You must be signed in to change notification settings - Fork 295
Windows 10 compilation
Here's a potential tutorial to help others who may encounter a similar issue when compiling a Rust project that relies on external libraries like WinPcap:
I encountered a similar issue when compiling my Rust project that depends on the WinPcap library (Packet.lib) on Windows. Here's how I resolved the "fatal error LNK1181: cannot open input file 'Packet.lib'" error:
-
Install the Windows SDK and WinPcap Developer Kit:
Make sure you have the Windows SDK and the WinPcap developer kit (v4.1.2 or your required version) installed on your system.
-
Locate the Packet.lib Library:
Find the
Packet.lib
library file on your system. In my case, I located it inC:\Users\erdt-cyber\Downloads\WpdPack_4_1_2\WpdPack\Lib\x64\Packet.lib
. This is the library we need to link to in our Rust project. -
Place Packet.lib in the Visual Studio Library Directory:
Copy the
Packet.lib
file to the Visual Studio library directory. The path may vary depending on your Visual Studio version and installation location. In my case, it was:C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\lib\x64\
Placing the library in this directory allows Visual Studio to find and link it during the build process.
-
Build Your Rust Project:
With the
Packet.lib
library in place and the correct path specified in yourCargo.toml
, you should be able to build your Rust project without encountering the LNK1181 error:cargo build --target x86_64-pc-windows-msvc
Make sure to adapt the commands and paths to match your specific setup.
By following these steps, you should be able to resolve the LNK1181 error and successfully compile your Rust project with WinPcap library dependencies.