[Solved] How to use libcap in Qt?
-
Hello firends.
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.
Ya Ali. -
I have a simple question.
I could find LIB path but how can I find INCLUDEPATH & DEPENDPATH? -
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/ -
58 decreased to 43 errors but strange errors exists such as:
memcmp was not declare ...
or
::memset has not been declared
etc
I dont use them & some of them are in qstring.h. -
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
@