How can I compile ndpiReader.c that comes with nDPI library in Windows?

雨燕双飞 提交于 2019-12-05 03:28:54

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!