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. Using Npcap with Qt Creator 6.4.3
Forum Updated to NodeBB v4.3 + New Features

Using Npcap with Qt Creator 6.4.3

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 2 Posters 617 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.
  • _ Offline
    _ Offline
    __d4ve__
    wrote on last edited by
    #1

    Hi all,

    I try to use npcap functions in Qt Creator

    Version : Qt Creator 10.0.1
    Based on Qt 6.4.3 (MSVC 2019, x86_64)

    Npcap 1.75

    same function works on visual studio 2022

    that's how i included npcap libraries :

    win32:CONFIG(release, debug|release): LIBS += -L$$PWD/'../../../../../../../Program Files/Npcap/Lib/' -lwpcap
    else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/'../../../../../../../Program Files/Npcap/Lib/' -lwpcap
    
    
    INCLUDEPATH += $$PWD/'../../../../../../../Program Files/Npcap/Include'
    DEPENDPATH += $$PWD/'../../../../../../../Program Files/Npcap/Include'
    

    the error i receive on compilation:

    mainwindow.obj:-1: error: LNK2019: unresolved external symbol pcap_findalldevs referenced in function "struct pcap_if * __cdecl find_devices(void)" (?find_devices@@YAPEAUpcap_if@@XZ)
    

    Here is the the piece of code that makes the error :

    pcap_if_t* find_devices()
    {
        pcap_if_t* alldevs = nullptr; // Initialize the pointer to nullptr
        char errbuf[PCAP_ERRBUF_SIZE];
        if (pcap_findalldevs(&alldevs, errbuf) == -1) {
            std::cerr << "Error finding network interfaces: " << errbuf << std::endl;
            return nullptr; // Return nullptr on error
        }
    
        return alldevs; // Return the pointer to pcap_if_t
    }
    
    JonBJ 1 Reply Last reply
    0
    • _ __d4ve__

      @JonB

      17:33:19: Running steps for project Packet_Capture_GUI...
      17:33:19: Configuration unchanged, skipping qmake step.
      17:33:19: Starting: "C:\QT\Tools\QtCreator\bin\jom\jom.exe" 
      	C:\QT\Tools\QtCreator\bin\jom\jom.exe -f Makefile.Debug
      	link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST:embed /OUT:debug\Packet_Capture_GUI.exe @C:\Users\Dave\AppData\Local\Temp\Packet_Capture_GUI.exe.23536.31.jom
      mainwindow.obj : error LNK2019: unresolved external symbol pcap_findalldevs referenced in function "struct pcap_if * __cdecl find_devices(void)" (?find_devices@@YAPEAUpcap_if@@XZ)
      C:\Program Files\Npcap\Lib\wpcap.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
      debug\Packet_Capture_GUI.exe : fatal error LNK1120: 1 unresolved externals
      jom: C:\Users\Dave\Desktop\C++ Exercises\Qt Creator Projects\Project 1 - Network Packet GUI\build-Packet_Capture_GUI-Desktop_Qt_6_5_1_MSVC2019_64bit-Debug\Makefile.Debug [debug\Packet_Capture_GUI.exe] Error 1120
      jom: C:\Users\Dave\Desktop\C++ Exercises\Qt Creator Projects\Project 1 - Network Packet GUI\build-Packet_Capture_GUI-Desktop_Qt_6_5_1_MSVC2019_64bit-Debug\Makefile [debug] Error 2
      17:33:20: The process "C:\QT\Tools\QtCreator\bin\jom\jom.exe" exited with code 2.
      Error while building/deploying project Packet_Capture_GUI (kit: Desktop Qt 6.5.1 MSVC2019 64bit)
      When executing step "Make"
      17:33:20: Elapsed time: 00:00.
      

      I have tried linking against 32bit and against 64bit and both as well

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by
      #6

      @__d4ve__ said in Using Npcap with Qt Creator 6.4.3:

      C:\Program Files\Npcap\Lib\wpcap.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'

      Until you resolve this nothing will link.

      _ 1 Reply Last reply
      2
      • _ __d4ve__

        Hi all,

        I try to use npcap functions in Qt Creator

        Version : Qt Creator 10.0.1
        Based on Qt 6.4.3 (MSVC 2019, x86_64)

        Npcap 1.75

        same function works on visual studio 2022

        that's how i included npcap libraries :

        win32:CONFIG(release, debug|release): LIBS += -L$$PWD/'../../../../../../../Program Files/Npcap/Lib/' -lwpcap
        else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/'../../../../../../../Program Files/Npcap/Lib/' -lwpcap
        
        
        INCLUDEPATH += $$PWD/'../../../../../../../Program Files/Npcap/Include'
        DEPENDPATH += $$PWD/'../../../../../../../Program Files/Npcap/Include'
        

        the error i receive on compilation:

        mainwindow.obj:-1: error: LNK2019: unresolved external symbol pcap_findalldevs referenced in function "struct pcap_if * __cdecl find_devices(void)" (?find_devices@@YAPEAUpcap_if@@XZ)
        

        Here is the the piece of code that makes the error :

        pcap_if_t* find_devices()
        {
            pcap_if_t* alldevs = nullptr; // Initialize the pointer to nullptr
            char errbuf[PCAP_ERRBUF_SIZE];
            if (pcap_findalldevs(&alldevs, errbuf) == -1) {
                std::cerr << "Error finding network interfaces: " << errbuf << std::endl;
                return nullptr; // Return nullptr on error
            }
        
            return alldevs; // Return the pointer to pcap_if_t
        }
        
        JonBJ Online
        JonBJ Online
        JonB
        wrote on last edited by
        #2

        @__d4ve__
        I would start by copying and pasting the exact full linker command being executed from Creator. And make sure your (embedded) ' (single-quote) quoting is good for Windows.

        _ 1 Reply Last reply
        0
        • JonBJ JonB

          @__d4ve__
          I would start by copying and pasting the exact full linker command being executed from Creator. And make sure your (embedded) ' (single-quote) quoting is good for Windows.

          _ Offline
          _ Offline
          __d4ve__
          wrote on last edited by __d4ve__
          #3

          @JonB If i understand you right that , you advise me changing the linked libraries to be with "

          I used 'Add Library' Functionality of Qt Creator to attach NPCAP

          anyway I tried that , same issue occurs

          JonBJ 1 Reply Last reply
          0
          • _ __d4ve__

            @JonB If i understand you right that , you advise me changing the linked libraries to be with "

            I used 'Add Library' Functionality of Qt Creator to attach NPCAP

            anyway I tried that , same issue occurs

            JonBJ Online
            JonBJ Online
            JonB
            wrote on last edited by
            #4

            @__d4ve__

            @JonB said in Using Npcap with Qt Creator 6.4.3:

            I would start by copying and pasting the exact full linker command being executed from Creator.

            _ 1 Reply Last reply
            0
            • JonBJ JonB

              @__d4ve__

              @JonB said in Using Npcap with Qt Creator 6.4.3:

              I would start by copying and pasting the exact full linker command being executed from Creator.

              _ Offline
              _ Offline
              __d4ve__
              wrote on last edited by
              #5

              @JonB

              17:33:19: Running steps for project Packet_Capture_GUI...
              17:33:19: Configuration unchanged, skipping qmake step.
              17:33:19: Starting: "C:\QT\Tools\QtCreator\bin\jom\jom.exe" 
              	C:\QT\Tools\QtCreator\bin\jom\jom.exe -f Makefile.Debug
              	link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST:embed /OUT:debug\Packet_Capture_GUI.exe @C:\Users\Dave\AppData\Local\Temp\Packet_Capture_GUI.exe.23536.31.jom
              mainwindow.obj : error LNK2019: unresolved external symbol pcap_findalldevs referenced in function "struct pcap_if * __cdecl find_devices(void)" (?find_devices@@YAPEAUpcap_if@@XZ)
              C:\Program Files\Npcap\Lib\wpcap.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
              debug\Packet_Capture_GUI.exe : fatal error LNK1120: 1 unresolved externals
              jom: C:\Users\Dave\Desktop\C++ Exercises\Qt Creator Projects\Project 1 - Network Packet GUI\build-Packet_Capture_GUI-Desktop_Qt_6_5_1_MSVC2019_64bit-Debug\Makefile.Debug [debug\Packet_Capture_GUI.exe] Error 1120
              jom: C:\Users\Dave\Desktop\C++ Exercises\Qt Creator Projects\Project 1 - Network Packet GUI\build-Packet_Capture_GUI-Desktop_Qt_6_5_1_MSVC2019_64bit-Debug\Makefile [debug] Error 2
              17:33:20: The process "C:\QT\Tools\QtCreator\bin\jom\jom.exe" exited with code 2.
              Error while building/deploying project Packet_Capture_GUI (kit: Desktop Qt 6.5.1 MSVC2019 64bit)
              When executing step "Make"
              17:33:20: Elapsed time: 00:00.
              

              I have tried linking against 32bit and against 64bit and both as well

              JonBJ 1 Reply Last reply
              0
              • _ __d4ve__

                @JonB

                17:33:19: Running steps for project Packet_Capture_GUI...
                17:33:19: Configuration unchanged, skipping qmake step.
                17:33:19: Starting: "C:\QT\Tools\QtCreator\bin\jom\jom.exe" 
                	C:\QT\Tools\QtCreator\bin\jom\jom.exe -f Makefile.Debug
                	link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST:embed /OUT:debug\Packet_Capture_GUI.exe @C:\Users\Dave\AppData\Local\Temp\Packet_Capture_GUI.exe.23536.31.jom
                mainwindow.obj : error LNK2019: unresolved external symbol pcap_findalldevs referenced in function "struct pcap_if * __cdecl find_devices(void)" (?find_devices@@YAPEAUpcap_if@@XZ)
                C:\Program Files\Npcap\Lib\wpcap.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
                debug\Packet_Capture_GUI.exe : fatal error LNK1120: 1 unresolved externals
                jom: C:\Users\Dave\Desktop\C++ Exercises\Qt Creator Projects\Project 1 - Network Packet GUI\build-Packet_Capture_GUI-Desktop_Qt_6_5_1_MSVC2019_64bit-Debug\Makefile.Debug [debug\Packet_Capture_GUI.exe] Error 1120
                jom: C:\Users\Dave\Desktop\C++ Exercises\Qt Creator Projects\Project 1 - Network Packet GUI\build-Packet_Capture_GUI-Desktop_Qt_6_5_1_MSVC2019_64bit-Debug\Makefile [debug] Error 2
                17:33:20: The process "C:\QT\Tools\QtCreator\bin\jom\jom.exe" exited with code 2.
                Error while building/deploying project Packet_Capture_GUI (kit: Desktop Qt 6.5.1 MSVC2019 64bit)
                When executing step "Make"
                17:33:20: Elapsed time: 00:00.
                

                I have tried linking against 32bit and against 64bit and both as well

                JonBJ Online
                JonBJ Online
                JonB
                wrote on last edited by
                #6

                @__d4ve__ said in Using Npcap with Qt Creator 6.4.3:

                C:\Program Files\Npcap\Lib\wpcap.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'

                Until you resolve this nothing will link.

                _ 1 Reply Last reply
                2
                • JonBJ JonB

                  @__d4ve__ said in Using Npcap with Qt Creator 6.4.3:

                  C:\Program Files\Npcap\Lib\wpcap.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'

                  Until you resolve this nothing will link.

                  _ Offline
                  _ Offline
                  __d4ve__
                  wrote on last edited by
                  #7

                  @JonB You are right , so I have linked it against the x64 bit and it works now , Thank you.

                  1 Reply Last reply
                  0
                  • _ __d4ve__ has marked this topic as solved on

                  • Login

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