PDA

View Full Version : how to avoid conflict in definitions when using Win32 SDK API header in Qt ?



captainst
30th March 2011, 06:24
Hello Everyone,

I've come across a problem when using the wlanapi (win32 native WIFI API) in Qt.

I included the wlanapi.h in my .cpp file. However, the compiler compains that wlanapi.h can not be found. So I added two include paths to my .pro file, like this:


INCLUDEPATH += "C:\Program Files\Microsoft SDKs\Windows\v6.1\Include" #this is the path to my wlanapi header
INCLUDEPATH += "C:\Program Files\Microsoft Visual Studio 9.0\VC\include" #this is the path to header files included by wlanapi.h

When compile, it shows up a lot of warning/errors which make me feel that the <QtCore/qglobal.h> has conflict with those win32's:



In file included from d:\Qt\2010.05\qt\include/QtCore/../../src/corelib/tools/qbytearray.h:48,

from d:\Qt\2010.05\qt\include/QtCore/qbytearray.h:1,

from d:\Qt\2010.05\qt\include/QtCore/../../src/corelib/tools/qstring.h:46,

from d:\Qt\2010.05\qt\include/QtCore/qstring.h:1,

from d:\Qt\2010.05\qt\include\QtCore/../../src/corelib/kernel/qobject.h:48,

from d:\Qt\2010.05\qt\include\QtCore/qobject.h:1,

from d:\Qt\2010.05\qt\include\QtCore/QObject:1,

c:\Program Files\Microsoft Visual Studio 9.0\VC\include/string.h:141: warning: ignoring #pragma warning

c:\Program Files\Microsoft Visual Studio 9.0\VC\include/string.h:142: warning: ignoring #pragma warning

c:\Program Files\Microsoft Visual Studio 9.0\VC\include/string.h:145: warning: ignoring #pragma warning

c:\Program Files\Microsoft Visual Studio 9.0\VC\include/string.h:266: warning: ignoring #pragma warning

c:\Program Files\Microsoft Visual Studio 9.0\VC\include/string.h:267: warning: ignoring #pragma warning

c:\Program Files\Microsoft Visual Studio 9.0\VC\include/string.h:269: warning: ignoring #pragma warning

Anybody knows how to resolve the conflict ? Many thanks in advance !

nish
30th March 2011, 07:47
what qt version you are using? QtSDK or compiled yourself? Using the VC2008 binary?

captainst
30th March 2011, 08:24
Thank you nish.

I am using the QtCreator 2.0.1 with Qt SDK ver 4.7.0. The QtSDK is installed, not recompiled. I am not using Visual Studio. I simply want to add some WiFi features to my current QtCreator project.

I have added #include <wlanapi.h> to my .cpp file. At first it complained that wlanapi.h can not be found, so I added the windows SDK path using "INCLUDEPATH +=" in .pro file. In this case the defines in qt head file get incasinated.

squidge
30th March 2011, 08:41
Or maybe just GCC doesn't fully understand the Visual studio-specific Win32 include files. You may need to modify them.

captainst
30th March 2011, 08:55
Or maybe just GCC doesn't fully understand the Visual studio-specific Win32 include files. You may need to modify them.

Thank you. I belive that modifying win32 headers is the last thing I would do ever.

I found this on google
http://qt.gitorious.org/qt-mobility/qt-mobility/blobs/19e5e3ac5ad4666f64c13a4b0a618e792836b7fb/bearer/qnativewifiengine_win.cpp

This file also contains #include <wlanapi.h>. However I have not managed to compile this project either -- the same problem.