Results 1 to 2 of 2

Thread: winpcap-dev+pthread+pcapplusplus makes qt window do not appear

  1. #1
    Join Date
    Mar 2017
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default winpcap-dev+pthread+pcapplusplus makes qt window do not appear

    Hello, folks.

    Here I have a problem.
    I was planning to make some kind of sniffer, just for practising. And so I started facing problems from the setup.

    So, basically program does not start.

    .pro file

    Qt Code:
    1. #-------------------------------------------------
    2. #
    3. # Project created by QtCreator 2017-03-16T17:23:52
    4. #
    5. #-------------------------------------------------
    6.  
    7. QT += core gui
    8.  
    9. greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    10.  
    11. TARGET = untitled
    12. TEMPLATE = app
    13. #CONFIG += c++11
    14. INCLUDEPATH += E:/lib/PcapPlusPlus-17.02-windows-mingw32-gcc-5.3.0/header
    15. LIBS += E:/lib/PcapPlusPlus-17.02-windows-mingw32-gcc-5.3.0/Pcap++.lib
    16. LIBS += E:/lib/PcapPlusPlus-17.02-windows-mingw32-gcc-5.3.0/Packet++.lib
    17. LIBS += E:/lib/PcapPlusPlus-17.02-windows-mingw32-gcc-5.3.0/Common++.lib
    18.  
    19. INCLUDEPATH += E:/lib/WpdPack/Include
    20. LIBS += -LE:/lib/WpdPack/Lib -lwpcap -lpacket
    21. LIBS += -lpthread
    22. LIBS += -lws2_32
    23. LIBS += -liphlpapi
    24. LIBS += -static-libgcc -static-libstdc++
    25.  
    26. SOURCES += main.cpp\
    27. sniffer.cpp
    28.  
    29. HEADERS += sniffer.h
    30.  
    31. FORMS += sniffer.ui
    To copy to clipboard, switch view to plain text mode 

    then goes sniffer.h

    Qt Code:
    1. #ifndef SNIFFER_H
    2. #define SNIFFER_H
    3. #include <winsock2.h>
    4. #include <QMainWindow>
    5.  
    6. namespace Ui {
    7. class Sniffer;
    8. }
    9.  
    10. class Sniffer : public QMainWindow
    11. {
    12. Q_OBJECT
    13.  
    14. public:
    15. explicit Sniffer(QWidget *parent = 0);
    16. ~Sniffer();
    17.  
    18. private slots:
    19. void on_pushButton_2_clicked();
    20.  
    21. private:
    22. Ui::Sniffer *ui;
    23. };
    24.  
    25. #endif // SNIFFER_H
    To copy to clipboard, switch view to plain text mode 

    .cpp

    Qt Code:
    1. #include "sniffer.h"
    2. #include "ui_sniffer.h"
    3.  
    4. #include <MacAddress.h>
    5. #include <IpAddress.h>
    6. #include <PlatformSpecificUtils.h>
    7. #include <PcapLiveDeviceList.h>
    8. #include <PcapLiveDevice.h>
    9. #include <EthLayer.h>
    10. #include <ArpLayer.h>
    11. #include <Logger.h>
    12. #include <QMessageBox>
    13.  
    14. using namespace pcpp;
    15. Sniffer::Sniffer(QWidget *parent) :
    16. QMainWindow(parent),
    17. ui(new Ui::Sniffer)
    18. {
    19. ui->setupUi(this);
    20. }
    21.  
    22. Sniffer::~Sniffer()
    23. {
    24. delete ui;
    25. }
    26.  
    27. void Sniffer::on_pushButton_2_clicked()
    28. {
    29. const std::vector <PcapLiveDevice*>& a = PcapLiveDeviceList::getInstance().getPcapLiveDevicesList();
    30. /*QString showme(*a[0]->getName());
    31.   QMessageBox::information(this, "info",showme);*/
    32. }
    To copy to clipboard, switch view to plain text mode 

    and main

    Qt Code:
    1. #include "sniffer.h"
    2. #include <QApplication>
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication a(argc, argv);
    7. Sniffer w;
    8. w.show();
    9.  
    10. return a.exec();
    11. }
    To copy to clipboard, switch view to plain text mode 


    so there's just 1 button and some headers.

    I was using dll for pthreads from somewhere here

    https://sourceforge.net/p/mingw-w64/...le%20pthreads/

    which I copied to /mingw53_32/bin

    precompiled pcapplusplus from.. here

    http://seladb.github.io/PcapPlusPlus-Doc/download.html

    and winpcap-dev from their site.

    when I try to run the app, it appears in memory, visible in taskmgr, but window with my fancy button doesn't show.

    Hope to your assistance, folks

  2. #2
    Join Date
    Mar 2017
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: winpcap-dev+pthread+pcapplusplus makes qt window do not appear

    And yes, working with developer of the PcapPlusPlus I figured out what was that. The thing is in some moment something went wrong to my environment, because my project was compiled and ran from the first time by dev without changes. So I created vm using wmvare with the same windows distribution (win7x64Ent), installed qt in it, placed libs and so everything just started to work with the first try.
    Qt Code:
    1. void Sniffer::on_pushButton_2_clicked()
    2. {
    3. const std::vector <PcapLiveDevice*>& a = PcapLiveDeviceList::getInstance().getPcapLiveDevicesList();
    4. for (auto it:a)
    5. QMessageBox::information(this, QString(it->getMacAddress().toString().c_str()),QString(it->getName()));
    6. }
    To copy to clipboard, switch view to plain text mode 

    so this code runs like this:

    qyAcxSq0d0.png

    So I would highly recommend to use vm or the whole clean system installation with the only qt|compiler instance in development. or at least have it, to test in good-working environment. Thanks for all views, hope this information will be helpful. And by the way, almost the same problem reports was found in this and some other forums, the guys was encountered almost the same problem but they have dependency-walker error messages about libraries with different cpu types. So they solved it by clean reinstallation of Qt and editing windows path variable to default when installing and then running project. That's all I have for now. Cheers.

Similar Threads

  1. Integrating Pthread Library with QT
    By bandarus in forum Newbie
    Replies: 2
    Last Post: 30th January 2017, 10:38
  2. problem in using pthread in QT
    By rinku in forum Newbie
    Replies: 4
    Last Post: 27th September 2012, 14:07
  3. -pthread havoc
    By Cruz in forum Qt Programming
    Replies: 8
    Last Post: 10th March 2010, 13:22
  4. pthread instead QThread
    By brevleq in forum Qt Programming
    Replies: 8
    Last Post: 23rd December 2008, 08:16
  5. Problem to compile with MinGW + Qt 4 + winpcap
    By jlbrd in forum Qt Programming
    Replies: 4
    Last Post: 4th May 2006, 17:32

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.