Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Mingw g++ fails on Win10 with Npcap



  • Hello
    Recently I had to move from win7 to win10. In my project I used WinPcap to catch UDP packets. According to official website WinPcap doesn't support win10, and they advice to use Npcap instead. So I installed Npcap from windows installer and downloaded SDK to use libraries in my project.
    But as soon as I build my project I get following error:

    g++.exe - Application Error
    The application was unable to start correctly (0xc0000142)
    

    Same error, that happened when I tried to build the project with old WinPcap SDK.
    I created a blank project, copied Npcap SDK (WpdPack) into it and as soon as I include Npcap to project

    //w10udptest.pro
    INCLUDEPATH += "C:/path_to_projects/w10udptest/WpdPack/Include"
    LIBS += -L "C:/path_to_projects/w10udptest/WpdPack/Lib" -lwpcap -lPacket
    
    //main.cpp
    #include "pcap.h"
    

    I get same g++ crash. Compile Output windows gives me this

    mingw32-make[1]: *** [Makefile.Debug:66: debug/w10udptest.exe] Error -1073741502
    mingw32-make[1]: Leaving directory 'C:/path_to_projects/build-w10udptest-Desktop_Qt_5_12_1_MinGW_64_bit-Debug'
    mingw32-make: *** [Makefile:38: debug] Error 2
    14:42:44: The process "D:\Programs\Qt\Tools\mingw730_64\bin\mingw32-make.exe" exited with code 2.
    Error while building/deploying project w10udptest (kit: Desktop Qt 5.12.1 MinGW 64-bit)
    When executing step "Make"
    

    I have already read this and this post, but looks like I have a combo..


  • Lifetime Qt Champion

    Hi @pavloponomarov,

    So you get a compiler crash while compiling?

    • Can you actually build and run a small Qt project without Npcap?
    • Please show a bit more compile output. From the few lines you showed, its impossible to tell where the compiler crashed.

    Regards



  • @aha_1980 said in Mingw g++ fails on Win10 with Npcap:

    Can you actually build and run a small Qt project without Npcap?

    Yes I do. I can even build and run the same test project if I comment the line that includes "pcap.h"

    @aha_1980 said in Mingw g++ fails on Win10 with Npcap:

    Please show a bit more compile output. From the few lines you showed, its impossible to tell where the compiler crashed.

    https://pastebin.com/gmcuuEK1
    That's all I get when I rebuild project


  • Lifetime Qt Champion

    @pavloponomarov So it seems it is really the linker that crashes.

    Are you sure the provided lib files are compatible to MinGW?

    And you are using MinGW 64 bit, it seems. Therefore you also need a 64bit lib.

    Regards



  • @aha_1980 said in Mingw g++ fails on Win10 with Npcap:

    And you are using MinGW 64 bit, it seems. Therefore you also need a 64bit lib.

    You're right, I use MinGW 64bit and I had to switch to Lib/x64 folder, which also contains Packet.lib and wpcap.lib

    LIBS += -L "C:/path_to_projects/w10udptest/WpdPack/Lib/x64" -lwpcap -lPacket
    

    Sadly, it didn't change anything. Still same g++ error. Compile Output is same, except for changed LIBS path in last command

    I have also tried to switch to 32-bit MinGW (changing LIBS again) and to compile 32-bit version - still no success.



  • You most likely need to compile the library from their sources yourself. I looked at their file that had the libs in it. There is no mention of MinGW. So it is most likely the libs are compiled using vc++. You need libs compiled using the MinGW compiler.



  • @fcarney
    Thank you!
    I'm not good at compiling sources in windows, but as workaround I installed MSVC 2017 devkit for Qt and it compiles!
    Works 100 times slower and I can't say if it's Npcap, Win10 or MSVC2017 problem.
    I guess I should switch to QUdpSocket


Log in to reply