Compiling Gopacket on Windows 64-bit
Problem:
When attempting to compile gopacket on Windows 10 for 64-bit (GOARCH=amd64), an error occurs indicating "File in wrong format" when adding wpcap symbols to the binary.
Solution:
To compile gopacket on Windows 64-bit successfully, follow these steps:
As the Winpcap developer's pack lacks Linux static libraries (libwpcap.a and libpacket.a), generate them manually:
dlltool --as-flags=--64 -m i386:x86-64 -k --output-lib libwpcap.a --input-def wpcap.def dlltool --as-flags=--64 -m i386:x86-64 -k --output-lib libpacket.a --input-def packet.def
With these steps completed, gopacket should compile without errors on Windows 64-bit.
The above is the detailed content of How to Compile Gopacket on Windows 64-bit with \'File in Wrong Format\' Error?. For more information, please follow other related articles on the PHP Chinese website!