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:
- Accept the default directories, and pick a mirror.
- 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:
- Download and unpack the Winpcap Developer's pack.
- 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 a pcap directory
- 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
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.
Open a CYGWIN terminal, and cd into the nDPI directory.
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.
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.
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
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.
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.