我如何编译ndpiReader.c附带nDPI库在Windows中? [英] How can I compile ndpiReader.c that comes with nDPI library in Windows?

查看:2125
本文介绍了我如何编译ndpiReader.c附带nDPI库在Windows中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要创建一个 ndpiReader.c 演示程序的<.exe> nDPI库。我成功地编译它在Ubuntu使用在他们的github页面上指定的命令如下:

  ./ autogen.sh 
./configure
make



我在Ubuntu中尝试使用GCC交叉编译我不成功。我也试图使用 pcapExample.sln 在Visual Studio 2012中编译它,但我不断收到错误消息:


错误29错误C1083:无法打开包含文件:'ndpi_api.h':没有此类文件或目录


虽然 ndpi_api.h 和所有其他文件,我得到这个错误已经在项目解决方案资源管理器中列出。
任何人实际上能够从这个 ndpiReader.c 文件中制作一个win32可执行文件?如果是,请指定步骤,要求或链接。



nDPI lib托管在此处: https://github.com/ntop/nDPI



ndpiReader.c 托管这里: https://github.com/ntop/nDPI/tree/dev/example



pcapExample.sln 位于此处:https://github.com/ntop/nDPI/tree/dev/example/Win32

解决方案

我从其他问题中看到,您已经尝试使用 CYGWIN 编译此问题,并遇到了



这里是我刚刚用于编译nDPI(包括ndpiReader.exe示例)的分步指南:



安装CYGWIN


  1. 接受默认目录, / li>
  2. 选择包步骤中,展开 Devel 类别,然后选择要安装的以下开发人员包:


    • autoconf

    • autoconf2.5

    • automake

    • automake1.15

    • binutils

    • cmake

    • cygwin-devel
    • li> gcc-core
    • gcc-tools-epoch2-autoconf

    • gcc-tools-epoch2-automake

    • libtool

    • make

    • pkg-config

    • w32api-headers

    • w32api-runtime


在CYGWIN下安装libpcap:


  1. 下载并解压缩 Winpcap开发人员包

  2. 将libpacket.a和libwpcap.a从WpdPack\Lib\复制到cygwin \lib \

  3. 在cygwin \lib中,将libwpcap.a复制到libpcap.a

  4. 在cygwin \usr\include中,创建一个pcap目录

  5. 将所有标头从WpdPack\Include复制到cygwin\usr\include\pcap

确保您已经安装了winpcap已经作为您尝试过的一部分,但是仔细检查必要的(packet.dll和wpcap.dll)库已经在cygwin \c\WINDOWS\ system32中。 / p>

现在您已经拥有了在Windows上编译nDPI所需的所有工具和库!



nDPI


  1. 在干净的目录中再次下载并解压nDPI,


  2. 打开CYGWIN终端,并进入nDPI目录。


  3. 执行autogen.sh

      ./ autogen.sh 



    这应该没有任何错误地完成。



    >

    p> 如果它停在缺少libpcap(-dev)库,请复查您在cygwin \lib中复制libpcap.a的先前步骤。


  4. autogen.sh应该开始为您运行配置阶段。 (如果没有,或者此阶段的一部分失败,您可以在修正任何问题后重新运行配置。)

      ./配置

    在检查了一些东西后,configure将通过创建Makefile结束。


  5. 通过运行make创建nDPI库。

      $ b  

    它将构建库,然后尝试构建示例,但失败,因为它找不到 pcap.h


  6. cd到示例目录中,并手动编译ndpiReader.c,添加 -I / usr / include / pcap 到命令:

      cd example / 
    gcc -DHAVE_CONFIG_H -I。 -I .. -I ../ src / include -I / usr / include / pcap -g -O2 -c -o ndpiReader.o ndpiReader.c

    我以我的命令为例。如果你的编译器命令略有不同,只需将-I / usr / include / pcap添加到您的Makefile调用的位置即可。


  7. 目录,并恢复make。

      cd .. 
    make



    最后一步将ndpiReader与ndpi库关联,并创建您要查找的可执行文件。



I want to create a .exe of ndpiReader.c demo program that comes with nDPI library. I was successful to compile it on Ubuntu using commands specified on their github page as bellow:

./autogen.sh
./configure
make

I have tried to cross compile it using GCC inside Ubuntu but I wasn't successful. I also tried to use the pcapExample.sln to compile it in Visual Studio 2012, but I keep getting error messages like:

Error 29 error C1083: Cannot open include file: 'ndpi_api.h': No such file or directory

Although ndpi_api.h and all other files that I get this error for already are listed in the project solution explorer. Has anyone actually been able to make a win32 executable out of this ndpiReader.c file? If yes, please specify the steps, requirements, or a link.

nDPI lib is hosted here: https://github.com/ntop/nDPI

ndpiReader.c is hosted here: https://github.com/ntop/nDPI/tree/dev/example

pcapExample.sln is hosted here: https://github.com/ntop/nDPI/tree/dev/example/Win32

解决方案

I saw from your other questions that you had already tried to compile this with CYGWIN and ran into a number of problems.

Here’s a step-by-step guide I just used to compile nDPI (including the ndpiReader.exe example):

Install CYGWIN:

  1. Accept the default directories, and pick a mirror.
  2. At the Select Packages step, expand the Devel category, and select the following developer packages to install:
    • autoconf
    • autoconf2.5
    • automake
    • automake1.15
    • binutils
    • cmake
    • cygwin-devel
    • gcc-core
    • gcc-tools-epoch2-autoconf
    • gcc-tools-epoch2-automake
    • libtool
    • make
    • pkg-config
    • w32api-headers
    • w32api-runtime

Install libpcap under CYGWIN:

  1. Download and unpack the Winpcap Developer's pack.
  2. Copy libpacket.a and libwpcap.a from WpdPack\Lib\ to cygwin\lib\
  3. In cygwin\lib, copy libwpcap.a to libpcap.a
  4. In cygwin\usr\include, create a pcap directory
  5. Copy all headers from WpdPack\Include to cygwin\usr\include\pcap

I'm sure you've installed winpcap already as part of everything else you've tried, but double-check that the necessary (packet.dll and wpcap.dll) libraries are already in cygwin\c\WINDOWS\system32.

Now you've got all the necessary tools and libraries to compile nDPI on Windows!

Building nDPI

  1. Download and unpack nDPI again in a clean directory, so you don't get tripped up by any issues from the previous build you tried.

  2. Open a CYGWIN terminal, and cd into the nDPI directory.

  3. Run autogen.sh

    ./autogen.sh
    

    This should complete without any errors.

    If it stops with "somepackage is missing: please install it and try again," you've missed installing a CYGWIN package that is needed to build the source.

    If it stops with "Missing libpcap(-dev) library," double-check the previous steps you did to copy libpcap.a in cygwin\lib.

  4. autogen.sh should start running the configure stage for you. (If it doesn't, or part of this stage fails, you can rerun configure after fixing any issue.)

    ./configure
    

    After checking for a number of things, configure will end by creating a Makefile.

  5. Build the nDPI library, by running make.

    make
    

    It will build the library, then try to build the examples, but fail because it can't find pcap.h

  6. cd into the example directory, and manually compile ndpiReader.c by adding -I/usr/include/pcap to the command:

    cd example/
    gcc -DHAVE_CONFIG_H -I. -I.. -I../src/include -I/usr/include/pcap -g -O2 -c -o ndpiReader.o ndpiReader.c
    

    I included my command as an example. If your compiler command is slightly different, just add -I/usr/include/pcap to what your Makefile had invoked.

  7. Leave the example directory, and resume the make.

    cd ..
    make
    

    This last step will link ndpiReader with the ndpi library, and create the executable you're looking for.

这篇关于我如何编译ndpiReader.c附带nDPI库在Windows中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆