将 VS2017 从 15.4.1 升级到 15.5.1 导致构建错误

Upgrading VS2017 from 15.4.1 to 15.5.1 resulted in build error(将 VS2017 从 15.4.1 升级到 15.5.1 导致构建错误)

本文介绍了将 VS2017 从 15.4.1 升级到 15.5.1 导致构建错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下工具/版本进行编程:Windows 10/VS2017 Professional/C++

升级到 15.5.1 后出现以下错误:

<块引用>

MIDL2338:开关是矛盾的 - no_robust 与 - 目标

Microsoft 编译器错误描述列表显示:编译 IDL 文件时,不能同时使用/osf 和/ms_ext 命令行开关.

我的项目属性中没有指定这些开关.

我尝试降级回 15.4.1,但发现无法恢复到旧版本,除非它是 N-1.这是基于我读过的许多博客(包括 Stack Overflow).

我碰壁了,一直处于停滞状态,直到我弄清楚这个开关问题.

非常感谢您的帮助.

解决方案

我刚才遇到了同样的问题,但幸运的是我可以访问另一个更旧的安装.

这里是VS 2017 15.4.4下的命令行:

/iid RtdHandleServer_i.c"/env win32/h RtdHandleServer.h"/W1/char 签名/tlb Win32ReleaseRtdHandleServer.tlb"/oicf/DNDEBUG"/no_robust/nologo/proxy RtdHandleServer_p.c"

这是在 VS 2017 15.5.1 下更改为的内容:

/iid RtdHandleServer_i.c"/env win32/h RtdHandleServer.h"/W1/char 签名/tlb Win32ReleaseRtdHandleServer.tlb"/oicf/目标NT60"/DNDEBUG"/no_robust/nologo/proxy RtdHandleServer_p.c"

所以所有的改变是添加了一个新参数/target "NT60",大概是作为一个新的默认值.

在我看来有两种方法可以解决这个问题:

  1. 在 idl 文件的属性页"对话框中,转到配置属性">中度>进阶,明确最小目标系统"的价值.
  2. 去掉 -no_robust 标志.根据文档(https://msdn.microsoft.com/en-us/library/windows/desktop/aa367349%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396):

<块引用>

如果生成的存根需要在 Microsoft Windows NT、Windows 95/98 或 Windows Me 上运行,则必须使用/no_robust 命令行开关来禁用/robust 功能."

就消除错误而言,任何一种更改都对我有效,但第一种方法的影响最小.

PS.我认为 MS 错误描述 (https://msdn.microsoft.com/en-us/library/windows/desktop/aa366756%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396) 在这种情况下可能不正确.您看到的原始错误消息是指两个特定标志,/no_robust/target,而不是 /osf/ms_ext.

注意: MIDL 编译器 /robust 开关执行以下操作(微软文档 MIDL 编译器:/robust 开关)

<块引用>

使用 /robust 开关生成额外的信息,允许网络数据表示 (NDR) 引擎执行运行时错误检查动态数组、联合和输入输出中的相关参数DCOM 应用程序中的接口指针./robust 开关仅在 Windows 2000 和更高版本的 Windows 下可用.

I'm programming with the following tools/versions: Windows 10 / VS2017 Professional / C++

After I upgraded to 15.5.1 I got the following error:

MIDL2338: switches are contradictory - no_robust vs. - target

The Microsoft compiler error description list says: You cannot use both the /osf and /ms_ext command-line switches when you compile an IDL file.

None of those switches are specified in my project properties.

I tried to downgrade back to 15.4.1 but have found that it's impossible to revert to an old version unless it's N-1. This is based on the many blogs I've read (including Stack Overflow).

I have hit a wall and am at a standstill until I figure out this switch issue.

Your help would be greatly appreciated.

解决方案

I ran into the same problem just now, but luckily I do have access to another, older, installation.

Here is the command line under VS 2017 15.4.4:

/iid "RtdHandleServer_i.c" /env win32 /h "RtdHandleServer.h" /W1 /char signed /tlb "Win32ReleaseRtdHandleServer.tlb" /Oicf /D "NDEBUG" /no_robust /nologo /proxy "RtdHandleServer_p.c" 

Here is what it is changed to under VS 2017 15.5.1:

/iid "RtdHandleServer_i.c" /env win32 /h "RtdHandleServer.h" /W1 /char signed /tlb "Win32ReleaseRtdHandleServer.tlb" /Oicf /target "NT60" /D "NDEBUG" /no_robust /nologo /proxy "RtdHandleServer_p.c" 

So all that has changed is that a new parameter /target "NT60" has been added, presumably as a new default.

It looks to me as if there are two ways to address this:

  1. In the Property Pages dialog for the idl file, go to Configuration Properties > MIDL > Advanced, and clear the value of "Minimum Target System".
  2. Get rid of the -no_robust flag. According to the documentation (https://msdn.microsoft.com/en-us/library/windows/desktop/aa367349%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396):

"The /no_robust command line switch must be used to disable the /robust feature if generated stubs need to run on Microsoft Windows NT, Windows 95/98, or Windows Me."

Either change works for me in terms of getting rid of the error, but the first method has the least impact.

PS. I think that the MS error description (https://msdn.microsoft.com/en-us/library/windows/desktop/aa366756%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396) is likely to be incorrect in this instance. The original error message that you are seeing refers to two specific flags, /no_robust and /target, not to /osf and /ms_ext.

Note: The MIDL compiler /robust switch does the following (Microsoft docs MIDL compiler: /robust switch)

Using the /robust switch generates additional information that allows the Network Data Representation (NDR) engine to perform run-time error checking on correlated arguments in dynamic arrays, unions, and in out interface pointers in DCOM applications. The /robust switch is only available under Windows 2000 and later versions of Windows.

这篇关于将 VS2017 从 15.4.1 升级到 15.5.1 导致构建错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:将 VS2017 从 15.4.1 升级到 15.5.1 导致构建错误

基础教程推荐