Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Qt Academy Launch in California!

    [Solved] How to use libcap in Qt?

    General and Desktop
    2
    11
    5343
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      MohammadReza 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.

      1 Reply Last reply Reply Quote 0
      • A
        andreyc 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
        @

        1 Reply Last reply Reply Quote 0
        • M
          MohammadReza last edited by

          I have a simple question.
          I could find LIB path but how can I find INCLUDEPATH & DEPENDPATH?

          1 Reply Last reply Reply Quote 0
          • A
            andreyc 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.

            1 Reply Last reply Reply Quote 0
            • M
              MohammadReza 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/

              1 Reply Last reply Reply Quote 0
              • A
                andreyc last edited by

                Your set of LIBS is incorrect. It should be
                @
                LIBS += -L/usr/lib/i386-linux-gnu -lpcap
                @

                1 Reply Last reply Reply Quote 0
                • M
                  MohammadReza 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.

                  1 Reply Last reply Reply Quote 0
                  • A
                    andreyc last edited by

                    Could you put the error log here.

                    1 Reply Last reply Reply Quote 0
                    • M
                      MohammadReza last edited by

                      A screen shot of some of the error:

                      !http://upload7.ir/imgs/2014-03/49544482189634377307.png(http://upload7.ir/imgs/2014-03/49544482189634377307.png)!

                      1 Reply Last reply Reply Quote 0
                      • M
                        MohammadReza 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.

                        1 Reply Last reply Reply Quote 0
                        • A
                          andreyc 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 Reply Last reply Reply Quote 0
                          • First post
                            Last post