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

I want to create the .exe of the ndpiReader.c demo program that comes with the nDPI library . I managed to compile it on Ubuntu using the commands specified on their github page, as shown below:

 ./autogen.sh ./configure make 

I tried to compile it using GCC inside Ubuntu, but I failed. I also tried using pcapExample.sln to compile it in Visual Studio 2012, but I keep getting error messages, for example:

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

Although ndpi_api.h and all other files for which I get this error are already listed in the project explorer. Has anyone really been able to make the win32 executable from this ndpiReader.c file? If yes, indicate steps, requirements or link.

nDPI This is where the lib is located: https://github.com/ntop/nDPI

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

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

+6
c ++ c compilation cross-compiling
source share
1 answer

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

Here is the walkthrough that I used to compile nDPI (including the ndpiReader.exe example):

Install CYGWIN:

  • Accept the default directories and select a mirror.
  • In 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 develop
    • NKA core
    • GCC-Tools-epoch2-Autoconf
    • GCC-Tools-epoch2-Automake
    • Libtool
    • to do
    • PKG configurations
    • w32api headers
    • w32api environment

Install libpcap in CYGWIN:

  • Download and unzip the Winpcap developer package .
  • Copy libpacket.a and libwpcap.a from WpdPack \ Lib \ to cygwin \ lib \
  • In cygwin \ lib copy libwpcap.a to libpcap.a
  • In cygwin \ usr \ include create the pcap directory
  • Copy all headers from WpdPack \ Include to cygwin \ usr \ include \ pcap

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

Now you have all the necessary tools and libraries for compiling nDPI on Windows!

Creating nDPI

  • Download and unzip nDPI again in a clean directory so that there are no problems with the previous version that you tried to run.

  • Open the CYGWIN and cd terminal in the nDPI directory.

  • Run autogen.sh

     ./autogen.sh 

    This should complete without error.

    If it stops at " somepackage is missing: install it and try again", you skipped installing the CYGWIN package, which is necessary to create the source.

    If it stops with "The libpcap (-dev) library is missing", double check the previous steps that you took to copy libpcap.a to cygwin \ lib.

  • autogen.sh should start the setup phase for you. (If this is not the case, or part of this step fails, you can restart the configuration after fixing any problem.)

     ./configure 

    After checking a few things, configure will end up creating a Makefile.

  • Create the nDPI library by running make.

     make 

    It will build the library and then try to create examples, but it will not work because it cannot find pcap.h

  • 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 

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

  • Leave the examples directory and resume make.

     cd .. make 

    This last step will link ndpiReader to the ndpi library and create the executable file you are looking for.

+2
source share

All Articles