[Solved] How to use libcap in Qt?
-
wrote on 24 Mar 2014, 04:47 last edited by
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. -
wrote on 24 Mar 2014, 05:12 last edited by
Have you added pcap library to .pro file?
Something like
@
LIBS += -L/path/to/libpcap
LIBS += -lpcap
INCLUDEPATH += /path/to/libpcap/headers
DEPENDPATH += /path/to/libpcap/headers
@ -
wrote on 24 Mar 2014, 05:29 last edited by
I have a simple question.
I could find LIB path but how can I find INCLUDEPATH & DEPENDPATH? -
wrote on 24 Mar 2014, 05:33 last edited by
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. -
wrote on 24 Mar 2014, 05:45 last edited by
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/ -
wrote on 24 Mar 2014, 05:47 last edited by
Your set of LIBS is incorrect. It should be
@
LIBS += -L/usr/lib/i386-linux-gnu -lpcap
@ -
wrote on 24 Mar 2014, 05:56 last edited by
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. -
wrote on 24 Mar 2014, 06:09 last edited by
Could you put the error log here.
-
wrote on 24 Mar 2014, 06:27 last edited by
A screen shot of some of the error:
-
wrote on 24 Mar 2014, 07:21 last edited by
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.
-
wrote on 24 Mar 2014, 16:24 last edited by
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
@
1/11