QT 4.8.5使用MinGW GCC 4.8.1编译问题

时间:2013-11-05 13:12:23

标签: qt4 mingw

所以我试图在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资源有问题吗?

感谢您的帮助!

1 个答案:

答案 0 :(得分: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标头wtypes.h http://sourceforge.net/p/mingw/bugs/2047 可以通过在wtypes.h中包含保护_WTYPES_H之前包含rpc.h和rpcndr.h来解决该问题。 触发错误的最小示例:

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

修复wtypes.h后,上面的例子应该是编译