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. Windows add pcap to project
Forum Updated to NodeBB v4.3 + New Features

Windows add pcap to project

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 2 Posters 2.6k Views 1 Watching
  • 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.
  • Z Offline
    Z Offline
    zwokaros
    wrote on last edited by
    #1

    I am having some troubles with adding the pcap lib to my Qt project on windows

    I have tried multiple examples I've found here and on other websites but in the end I always have the same message "pcap.h No such file or directory" after trying to include it in my main.cpp file

    #include "mainwindow.h"
    #include <QApplication>
    #include <winsock2.h>
    #include <pcap.h>
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        MainWindow w;
        w.show();
    
        return a.exec();
    }
    

    This is what I have so far in my main.cpp

    #-------------------------------------------------
    #
    # Project created by QtCreator 2018-05-28T03:27:57
    #
    #-------------------------------------------------
    
    QT       += core gui
    
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    TARGET = hello
    TEMPLATE = app
    
    
    SOURCES += main.cpp\
            mainwindow.cpp
    
    HEADERS  += mainwindow.h\
    
    FORMS    += mainwindow.ui
    
    INCLUDEPATH += C:/WpdPack/Include
    LIBS += "-LC:/WpdPack/Lib" -lwpcap -lws2_32
    
    DEFINES += HAVE_REMOTE
    DEFINES += WPCAP
    

    And this is my .pro file

    I installed WpdPack at the root of C:/

    Any idea why it autocompletes pcap.h when I'm including it but still displays an error when I compile/run it?

    Also I think it comes from the pcap.h file that has this line (and only this line)

    #include <pcap/pcap.h>
    
    

    Thanks

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      What exact error do you have ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      Z 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi and welcome to devnet,

        What exact error do you have ?

        Z Offline
        Z Offline
        zwokaros
        wrote on last edited by
        #3

        @SGaist "pcap.h" no such file or diretory, and it's only for this .h file

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Where is that file located on your system ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          Z 1 Reply Last reply
          1
          • SGaistS SGaist

            Where is that file located on your system ?

            Z Offline
            Z Offline
            zwokaros
            wrote on last edited by
            #5

            @SGaist C:/WpdPack/Include/pcap.h

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Then your include statement is wrong, it should just be #include <pcap.h>

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              Z 1 Reply Last reply
              0
              • SGaistS SGaist

                Then your include statement is wrong, it should just be #include <pcap.h>

                Z Offline
                Z Offline
                zwokaros
                wrote on last edited by
                #7

                @SGaist I still have the same error "pcap No such file or directory"

                1 Reply Last reply
                0
                • Z Offline
                  Z Offline
                  zwokaros
                  wrote on last edited by
                  #8

                  Okay so I ended up putting the header files directly into my project instead of writing the path in the .pro file
                  Now it's working

                  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