5

所以我正在尝试在 Qt 中构建我的开发环境,就像我过去做过很多次一样。我从一个完全干净的操作系统安装开始,我从网站上获得了最新的 MinGW 和 MSYS 包。我通过 git 获得了 Qt 4.8.5 的源代码,导出了 v4.8.5 的标签。整个 Qt 库构建良好,但是当它构建插件时,它在 nativewifi 插件上失败,并出现非常低级的类型错误。

(“mingw32-make sub-plugins”的输出;其余模块已经构建成功)

cd src\plugins\ && mingw32-make -f Makefile
mingw32-make[1]: Entering directory 'C:/Qt/Qt-4.8.5_mingw/src/plugins'
cd sqldrivers\ && mingw32-make -f Makefile 
mingw32-make[2]: Entering directory 'C:/Qt/Qt-4.8.5_mingw/src/plugins/sqldrivers'
cd mysql\ && mingw32-make -f Makefile 
mingw32-make[3]: Entering directory 'C:/Qt/Qt-4.8.5_mingw/src/plugins/sqldrivers/mysql'
mingw32-make -f Makefile.Debug all
mingw32-make[4]: Entering directory 'C:/Qt/Qt-4.8.5_mingw/src/plugins/sqldrivers/mysql'
mingw32-make[4]: Nothing to be done for 'all'.
mingw32-make[4]: Leaving directory 'C:/Qt/Qt-4.8.5_mingw/src/plugins/sqldrivers/mysql'
mingw32-make -f Makefile.Release all
mingw32-make[4]: Entering directory 'C:/Qt/Qt-4.8.5_mingw/src/plugins/sqldrivers/mysql'
mingw32-make[4]: Nothing to be done for 'all'.
mingw32-make[4]: Leaving directory 'C:/Qt/Qt-4.8.5_mingw/src/plugins/sqldrivers/mysql'
mingw32-make[3]: Leaving directory 'C:/Qt/Qt-4.8.5_mingw/src/plugins/sqldrivers/mysql'
cd sqlite\ && mingw32-make -f Makefile 
mingw32-make[3]: Entering directory 'C:/Qt/Qt-4.8.5_mingw/src/plugins/sqldrivers/sqlite'
mingw32-make -f Makefile.Debug all
mingw32-make[4]: Entering directory 'C:/Qt/Qt-4.8.5_mingw/src/plugins/sqldrivers/sqlite'
mingw32-make[4]: Nothing to be done for 'all'.
mingw32-make[4]: Leaving directory 'C:/Qt/Qt-4.8.5_mingw/src/plugins/sqldrivers/sqlite'
mingw32-make -f Makefile.Release all
mingw32-make[4]: Entering directory 'C:/Qt/Qt-4.8.5_mingw/src/plugins/sqldrivers/sqlite'
mingw32-make[4]: Nothing to be done for 'all'.
mingw32-make[4]: Leaving directory 'C:/Qt/Qt-4.8.5_mingw/src/plugins/sqldrivers/sqlite'
mingw32-make[3]: Leaving directory 'C:/Qt/Qt-4.8.5_mingw/src/plugins/sqldrivers/sqlite'
mingw32-make[2]: Leaving directory 'C:/Qt/Qt-4.8.5_mingw/src/plugins/sqldrivers'
cd script\ && mingw32-make -f Makefile 
mingw32-make[2]: Entering directory 'C:/Qt/Qt-4.8.5_mingw/src/plugins/script'
mingw32-make[2]: Nothing to be done for 'first'.
mingw32-make[2]: Leaving directory 'C:/Qt/Qt-4.8.5_mingw/src/plugins/script'
cd bearer\ && mingw32-make -f Makefile 
mingw32-make[2]: Entering directory 'C:/Qt/Qt-4.8.5_mingw/src/plugins/bearer'
cd generic\ && mingw32-make -f Makefile 
mingw32-make[3]: Entering directory 'C:/Qt/Qt-4.8.5_mingw/src/plugins/bearer/generic'
mingw32-make -f Makefile.Debug all
mingw32-make[4]: Entering directory 'C:/Qt/Qt-4.8.5_mingw/src/plugins/bearer/generic'
mingw32-make[4]: Nothing to be done for 'all'.
mingw32-make[4]: Leaving directory 'C:/Qt/Qt-4.8.5_mingw/src/plugins/bearer/generic'
mingw32-make -f Makefile.Release all
mingw32-make[4]: Entering directory 'C:/Qt/Qt-4.8.5_mingw/src/plugins/bearer/generic'
mingw32-make[4]: Nothing to be done for 'all'.
mingw32-make[4]: Leaving directory 'C:/Qt/Qt-4.8.5_mingw/src/plugins/bearer/generic'
mingw32-make[3]: Leaving directory 'C:/Qt/Qt-4.8.5_mingw/src/plugins/bearer/generic'
cd nativewifi\ && mingw32-make -f Makefile 
mingw32-make[3]: Entering directory 'C:/Qt/Qt-4.8.5_mingw/src/plugins/bearer/nativewifi'
mingw32-make -f Makefile.Debug all
mingw32-make[4]: Entering directory 'C:/Qt/Qt-4.8.5_mingw/src/plugins/bearer/nativewifi'
g++ -c -pipe -fno-keep-inline-dllexport -g -frtti -fexceptions -mthreads -Wall -Wextra -DUNICODE -DQT_DLL -DQT_PLUGIN -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -I"..\..\..\..\include\QtCore" -I"..\..\..\..\include\QtNetwork" -I"..\..\..\..\include" -I"..\..\..\..\include\ActiveQt" -I"tmp\moc\debug_shared" -I"..\..\..\..\mkspecs\win32-g++-4.6" -o tmp\obj\debug_shared\main.o main.cpp
In file included from c:\mingw\include\objbase.h:95:0,
                 from c:\mingw\include\ole2.h:31,
                 from c:\mingw\include\windows.h:101,
                 from c:\mingw\include\rpc.h:27,
                 from c:\mingw\include\wtypes.h:29,
                 from platformdefs.h:45,
                 from main.cpp:43:
c:\mingw\include\objidl.h:69:2: error: 'LPOLESTR' does not name a type
  LPOLESTR pwcsName;
  ^
c:\mingw\include\objidl.h:113:9: error: 'OLECHAR' does not name a type
 typedef OLECHAR **SNB;
         ^
c:\mingw\include\objidl.h:259:2: error: 'OLECHAR' does not name a type
  OLECHAR rgString[1];
  ^
c:\mingw\include\objidl.h:302:2: error: 'CY' does not name a type
  CY *pElems;
  ^
c:\mingw\include\objidl.h:306:2: error: 'DATE' does not name a type
  DATE *pElems;
  ^
c:\mingw\include\objidl.h:310:2: error: 'BSTR' does not name a type
  BSTR  *pElems;
  ^
c:\mingw\include\objidl.h:314:2: error: 'BSTRBLOB' does not name a type
  BSTRBLOB *pElems;
  ^
c:\mingw\include\objidl.h:318:2: error: 'VARIANT_BOOL' does not name a type
  VARIANT_BOOL *pElems;
  ^
c:\mingw\include\objidl.h:322:2: error: 'SCODE' does not name a type
  SCODE *pElems;
  ^
c:\mingw\include\objidl.h:346:2: error: 'CLIPDATA' does not name a type
  CLIPDATA *pElems;
  ^
c:\mingw\include\objidl.h:358:2: error: 'VARTYPE' does not name a type
  VARTYPE vt;
  ^
... (much more output, but similar to the above errors)

为什么一切都正确构建,并且只有当它尝试构建nativewifi时才知道 LPOLESTR 是什么?我在某处缺少依赖项吗?我是否错误地安装了 MinGW?我的 Qt 资源有问题吗?

谢谢您的帮助!

4

1 回答 1

11

这绝对是 mingw 的标题问题。我已经测试了一个快速而肮脏的解决方案来解决这个问题:转到文件夹 ...\qt-everywhere-opensource-4.8.x\src\plugins\bearer\nativewifi 并打开以下 2 个文件:qnativewifiengine.cpp 和 main .cpp。在第一个包含行之前按如下方式修改这两个文件: #include<windows.h> 并保存这两个文件。

然后再次尝试编译,它应该可以工作。在我的情况下它确实有效:) 我相信这要么是头文件中的递归包含,因为并非 mingw 头文件中的每个包含都被包含保护“保护”,或者它是 windows.h 的缺失依赖项,这可能是错误的评估。 ..

main.cpp 中的示例:

#include <windows.h>
#include "qnativewifiengine.h"
#include "platformdefs.h"

#include <QtCore/private/qsystemlibrary_p.h>

#include <QtNetwork/private/qbearerplugin_p.h>

要修复它不是又快又脏,你必须修复 mingw header wtypes.h http://sourceforge.net/p/mingw/bugs/2047 这个问题可以通过在包含保护 _WTYPES_H 之前包含 rpc.h 和 rpcndr.h 来解决在 wtypes.h 中触发错误的最小示例:

#include <wtypes.h>
int main()
{
}

修复 wtypes.h 后,上面的示例应该可以编译

于 2014-01-24T07:26:37.633 回答