且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Windows 64位上编译gopacket

更新时间:2022-04-16 02:22:15

好的,所以我知道了.
为了在Windows上编译gopacket 64bit,您需要执行以下操作:

OK so I have figured it out.
In order to compile gopacket 64bit on windows you need to do the following:

  1. 安装go_amd64(将go二进制文件添加到您的PATH中)
  2. 安装TDM GCC x64(将TDM-GCC二进制文件添加到PATH)
  3. 还将TDM-GCC \ x86_64-w64-mingw32 \ bin添加到您的PATH
  4. 安装 Winpcap
  5. 下载Winpcap开发人员包并将其解压缩到C:\
  1. Install go_amd64 (add go binaries to your PATH)
  2. Install TDM GCC x64 (add TDM-GCC binaries to your PATH)
  3. Also add TDM-GCC\x86_64-w64-mingw32\bin to your PATH
  4. Install Winpcap
  5. Download Winpcap developer's pack and extract it to C:\

现在的要点是缺少linux静态库文件
(libwpcap.a和libpacket.a)来自lib/x64文件夹.我不知道为什么他们不是
包含在开发人员包中,但无论如何,这就是我们生成它们的方式:

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:

  1. 在您的PC中找到wpcap.dll和packet.dll(通常在c:\ windows \ system32
  2. 中)
  3. 将它们复制到其他临时文件夹中,否则您将必须为以下命令提供管理员权限
  4. 在那些文件 gendef wpcap.dll gendef packet.dll 上运行gendef(可通过MinGW Installation Manager获得,软件包mingw32-gendef)
  5. 这将生成.def文件
  6. 现在,我们将生成静态库文件:
  7. 运行 dlltool --as-flags =-64 -m i386:x86-64 -k --output-lib libwpcap.a --input-def wpcap.def
  8. dlltool --as-flags =-64 -m i386:x86-64 -k --output-lib libpacket.a --input-def packet.def
  9. 现在只需将libwpcap.a和libpacket.a复制到c:\ WpdPack \ Lib \ x64
  1. find wpcap.dll and packet.dll in your PC (typically in c:\windows\system32
  2. copy them to some other temp folder or else you'll have to supply Admin privs to the following commands
  3. run gendef on those files gendef wpcap.dll and gendef packet.dll (obtainable with MinGW Installation Manager, package mingw32-gendef)
  4. this will generate .def files
  5. Now we'll generate the static libraries files:
  6. run dlltool --as-flags=--64 -m i386:x86-64 -k --output-lib libwpcap.a --input-def wpcap.def
  7. and dlltool --as-flags=--64 -m i386:x86-64 -k --output-lib libpacket.a --input-def packet.def
  8. Now just copy both libwpcap.a and libpacket.a to c:\WpdPack\Lib\x64

就是这样.
现在gopacket应该可以编译了.

That's it.
Now gopacket should compile with no problems.