将Windows C ++项目从Qt4移动到5会产生数百个看似无关的编译错误

时间:2022-02-13 23:41:22

I upgraded to Qt5/msvc2010 and am now trying to build a project using Qt Creator that was working fine with Qt4/msvc2008 (no source code has changed since it was working).

我升级到Qt5 / msvc2010,现在正在尝试使用Qt Creator构建一个项目,该项目与Qt4 / msvc2008一起工作正常(自从它工作以来没有源代码发生变化)。

The project uses some COM elements to talk to external audio recording devices via an Olympus SDK.

该项目使用一些COM元素通过Olympus SDK与外部录音设备通信。

What could cause all of these errors when everything was working fine before I upgraded to Qt5? To my knowledge none of the classes listed in these errors are actually used by my project.

在升级到Qt5之前,当一切正常时,会导致所有这些错误的原因是什么?据我所知,我的项目实际上并没有使用这些错误中列出的类。

I've tried including files that define the classes in question (e.g. ocidl.h for IEnumConnections) in every header file possible, even switching the order of includes to many different combinations to no avail.

我已经尝试在每个头文件中包含定义所讨论的类的文件(例如,IEnumConnections的ocidl.h),甚至可以将包含顺序切换为许多不同的组合,但无济于事。

e:\bp\mainwindow.h(21) : warning C4005: 'WINVER' : macro redefinition
        C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\sdkddkver.h(212) : see previous definition of 'WINVER'
e:\bp\mainwindow.h(25) : warning C4005: '_WIN32_WINNT' : macro redefinition
        C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\sdkddkver.h(197) : see previous definition of '_WIN32_WINNT'
C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ocidl.h(53) : error C2146: syntax error : missing ';' before identifier 'IEnumConnections'
C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ocidl.h(53) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ocidl.h(53) : error C2146: syntax error : missing ';' before identifier 'IEnumConnections'
C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ocidl.h(53) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ocidl.h(53) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ocidl.h(53) : error C2086: 'int IEnumConnections' : redefinition
        C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ocidl.h(53) : see declaration of 'IEnumConnections'
C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ocidl.h(59) : error C2146: syntax error : missing ';' before identifier 'IConnectionPoint'
C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ocidl.h(59) : warning C4091: '' : ignored on left of 'interface' when no variable is declared
C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ocidl.h(65) : error C2146: syntax error : missing ';' before identifier 'IEnumConnectionPoints'
C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ocidl.h(65) : warning C4091: '' : ignored on left of 'interface' when no variable is declared
C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ocidl.h(71) : error C2146: syntax error : missing ';' before identifier 'IConnectionPointContainer'
C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ocidl.h(71) : warning C4091: '' : ignored on left of 'interface' when no variable is declared
C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ocidl.h(77) : error C2146: syntax error : missing ';' before identifier 'IClassFactory2'
C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ocidl.h(77) : warning C4091: '' : ignored on left of 'interface' when no variable is declared
C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ocidl.h(83) : error C2146: syntax error : missing ';' before identifier 'IProvideClassInfo'
C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ocidl.h(83) : warning C4091: '' : ignored on left of 'interface' when no variable is declared
C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ocidl.h(89) : error C2146: syntax error : missing ';' before identifier 'IProvideClassInfo2'
C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ocidl.h(89) : warning C4091: '' : ignored on left of 'interface' when no variable is declared

Full error listing is here: http://dpaste.com/1525608/

完整的错误列表在这里:http://dpaste.com/1525608/

2 个解决方案

#1


3  

The windows inclusion has been changed in Qt 5. You will need to include the windows.h after your sdkddkver.h inclusion.

在Qt 5中更改了窗口包含。在包含sdkddkver.h之后,您需要包含windows.h。

#2


1  

Try moving #include "windows.h" above all your other includes, and/or above every reference to olympus sdk.

尝试将#include“windows.h”移到所有其他包含上方,和/或高于每个对奥林巴斯sdk的引用。

Also do a full build clean. Including deleting any Makefile, or Makefile.debug and your debug and release folders.

还要做一个完整的构建清洁。包括删除任何Makefile,或Makefile.debug以及您的调试和发布文件夹。

If that still doesn't fix it, turn of shadow building.

如果仍然无法修复它,请转动阴影构建。

Hope that helps.

希望有所帮助。

#1


3  

The windows inclusion has been changed in Qt 5. You will need to include the windows.h after your sdkddkver.h inclusion.

在Qt 5中更改了窗口包含。在包含sdkddkver.h之后,您需要包含windows.h。

#2


1  

Try moving #include "windows.h" above all your other includes, and/or above every reference to olympus sdk.

尝试将#include“windows.h”移到所有其他包含上方,和/或高于每个对奥林巴斯sdk的引用。

Also do a full build clean. Including deleting any Makefile, or Makefile.debug and your debug and release folders.

还要做一个完整的构建清洁。包括删除任何Makefile,或Makefile.debug以及您的调试和发布文件夹。

If that still doesn't fix it, turn of shadow building.

如果仍然无法修复它,请转动阴影构建。

Hope that helps.

希望有所帮助。