I am trying to use gopacket on my windows 10.
I'm using it to sniff and inject packets directly to/from the NIC.
I can easily compile and run my code with GOARCH=386 but can't in GOARCH=amd64.
Worth noticing: I am NOT trying to cross-compile.
I'm using go1.6.windows-386 to compile the 32bit version and when I try to compile with GOARCH=amd64 I use go1.6.windows-amd64.
I used TDM-GCC as linux like compile tools.
The error isn't indicative. it just says
c:/WpdPack/Lib/x64/wpcap.lib: error adding symbols: File in wrong format
collect2.exe: error ld returned 1 exit status
Did anyone manage to build this, if it's even possible?
OK so I have figured it out.
In order to compile gopacket 64bit on windows you need to do the following:
Now the point is that there are missing linux static libraries files
(libwpcap.a and libpacket.a) from lib/x64 folder. I don't know why they weren't
included in the developers pack but anyway that's how we can generate them:
gendef wpcap.dll
and gendef packet.dll
(obtainable with MinGW Installation Manager, package mingw32-gendef)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
That's it.
Now gopacket should compile with no problems.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With