Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] How to use libcap in Qt?

[Solved] How to use libcap in Qt?

Scheduled Pinned Locked Moved General and Desktop
11 Posts 2 Posters 6.1k Views
  • 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 Offline
    M Offline
    MohammadReza
    wrote on last edited by
    #1

    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
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      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
      0
      • M Offline
        M Offline
        MohammadReza
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andreyc
          wrote on last edited by
          #4

          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
          0
          • M Offline
            M Offline
            MohammadReza
            wrote on last edited by
            #5

            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
            0
            • A Offline
              A Offline
              andreyc
              wrote on last edited by
              #6

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

              1 Reply Last reply
              0
              • M Offline
                M Offline
                MohammadReza
                wrote on last edited by
                #7

                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
                0
                • A Offline
                  A Offline
                  andreyc
                  wrote on last edited by
                  #8

                  Could you put the error log here.

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    MohammadReza
                    wrote on last edited by
                    #9

                    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
                    0
                    • M Offline
                      M Offline
                      MohammadReza
                      wrote on last edited by
                      #10

                      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
                      0
                      • A Offline
                        A Offline
                        andreyc
                        wrote on last edited by
                        #11

                        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
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved