PDA

View Full Version : Problem to compile with MinGW + Qt 4 + winpcap



jlbrd
4th May 2006, 14:20
Hello,

I want to use winpcap on Qt 4 program, but I have compilation errors if I include pcap header files with Qt headers. Here's an little example :
main.cpp


#include <pcap.h>
#include <remote-ext.h>

#include <QApplication>
#include <QDialog>

int main(int argc, char ** argv)
{
QApplication app(argc, argv);
QDialog *window = new QDialog;

window->show();
return app.exec();
}

and project file


SOURCES = main.cpp
win32:LIBS += -LC:\WpdPack\Lib -lwpcap
win32:INCLUDEPATH += C:\WpdPack\include

With Visual studio no errors. With minGW :


from C:/Qt/4.1.1-gw/include/QtGui/qapplication.h:1,
from C:/Qt/4.1.1-gw/include/QtGui/QApplication:1,
from main.cpp:4:
C:/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/mingw32/bits
/c++locale.h: In function `int std::__convert_from_v(char*, int, const char*, _T
v, int* const&, int)':
C:/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/mingw32/bits
/c++locale.h:68: error: `snprintf' is not a member of `std'
mingw32-make[1]: *** [release\main.o] Error 1
mingw32-make[1]: Leaving directory `C:/Documents and Settings/jl/Mes documents/e
ssaigcc'
mingw32-make: *** [release] Error 2

It's the last lines of errors compilation.
If I delete pcap headers, no error. If I delete Qt code and headers, no error !
Thanks for help

jacek
4th May 2006, 14:59
Try:
#include <QApplication>
#include <QDialog>

#include <pcap.h>
#include <remote-ext.h>

int main(int argc, char ** argv)
{
...
}

jlbrd
4th May 2006, 15:12
Thanks you very much ! It's good

do you have an explanation?

jacek
4th May 2006, 15:46
do you have an explanation?
Unfortunately not, I've just run into similar problem when I tried to use STL in my application.

jlbrd
4th May 2006, 16:32
Ok thank you