[Solved] How to use libcap in Qt?
First excuse me because of my English writing.
I want to create an application by libpcap in Qt in Kali linux. I create similar application in windows & does work.
I download & install libpcap. Now, Qt recognizes pcap.h but some functions & constants does not work. like as: pcap_open - PCAP_OPENFLAG_PROMISCUOUS - pcap_findalldevs_ex - PCAP_SRC_IF_STRING - _snprintf_s.
The compiler errors similar as 'sth' was not declared in this scope. I use below headers but above errors apppear.
Are there anything to add to .pro file?
Thanks a lot.
Have you added pcap library to .pro file?
LIBS += -L/path/to/libpcap
LIBS += -lpcap
INCLUDEPATH += /path/to/libpcap/headers
DEPENDPATH += /path/to/libpcap/headers
I have a simple question.
I could find LIB path but how can I find INCLUDEPATH & DEPENDPATH?
These variables should point to the directory where pcap.h is located.
If you don't have pcap.h then you need to install dev package.
Thanks for your response Dear andreyc.
I added these code but 5 errors increased to 58 errors:
LIBS += -L/usr/lib/i386-linux-gnu/libpcap.so.1.3.0
INCLUDEPATH += /usr/include/pjlib-util/
Your set of LIBS is incorrect. It should be
LIBS += -L/usr/lib/i386-linux-gnu -lpcap
58 decreased to 43 errors but strange errors exists such as:
memcmp was not declare ...
::memset has not been declared
I dont use them & some of them are in qstring.h.
Could you put the error log here.
A screen shot of some of the error:
I thinks the above strange errors occured by INCLUDEPATH.
I replcae above code by this one & change some functions:
LIBS += -L/usr/local/lib/ -lpcap
now Just these errors:
pcap_open, PCAP_OPENFLAG_PROMISCUOUS and PCAP_SRC_IF_STRING was not declared in this code.
I searched & I think above functions & constants does not exist in libpcap (just exist in winpcap)
However, Thake be to GOD & Thanks to Dear andreyc.
Glad to hear that you've resolved the issue.
Could you put "[SOLVED]" in front your initial subject that other people will see that the issue is resolved.
Regarding many errors introduced by INCLUDEPATH
I guess you missed plus sign in you .pro files and made all standard headers invisible for qmake.
It is important to use '+=' not just '=' in INCLUDEPATH
INCLUDEPATH += /some/additional/path/that/wont/break/build