我正在尝试使用Visual Studio 2017作为Dymola 2019中的编译器。我已经在VS2017中为C++安装了所有组件(据我所知)。但是,当我尝试在Dymola中测试编译器时,出现如下错误消息:

Compiling and linking the model (Visual C++).

**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.9.11
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x86'
"Testing 32-bit compilation"
dsmodel.c
dsmodel.c(1): fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory

Error generating Dymosim.

我也尝试使用Visual Studio 2015,但同样失败。
Compiling and linking the model (Visual C++).

ERROR: Cannot determine the location of the VS Common Tools folder.
"Testing 32-bit compilation"
'cl' is not recognized as an internal or external command,
operable program or batch file.

Error generating Dymosim.

我也无法在VS2017文件夹中的任何位置找到stdio.h。但是它位于程序文件中单独的文件夹WindowsSDK中。

编译器测试应该可以正常工作(至少从我过去对dymola和VS的经验来看,不确定这些工具的较新版本是否引起困惑)

最佳答案

只是为了完成此操作,因为我还遇到了我具有管理员权限,但无法访问注册表的问题,因此Dymola抛出了编译器错误。有两种可能性:

  • 从IT获得对注册表的访问。
  • 如果由于限制而无法执行此操作。 Eiter安装了一个绕过注册表或手动更改路径的工具,我建议您这样做,因为这些工具不太严重。

  • 这是至少如何更改VS2013路径的解决方案。首先,您需要以管理员身份打开的文本编辑器中的vcvars32.bat中打开%ProgramFiles(x86)%\Microsoft Visual Studio 12.0\VC\bin\。在那里,您需要注释掉前3行,这将执行不可能设置多个路径的注册表调用。之后,您需要在vcvars32.bat中手动设置这些路径。最后,vcvars32.bat的开头应如下所示:
        :: @call :GetVSCommonToolsDir
        :: @if "%VS120COMNTOOLS%"=="" goto error_no_VS120COMNTOOLSDIR
    
        :: @call "%VS120COMNTOOLS%VCVarsQueryRegistry.bat" 32bit No64bit
    
        @SET VSINSTALLDIR=%ProgramFiles(x86)%\Microsoft Visual Studio 12.0\
        @SET VCINSTALLDIR=%ProgramFiles(x86)%\Microsoft Visual Studio 12.0\VC\
        @SET FrameworkDir32=c:\Windows\Microsoft.NET\Framework\
        @SET FrameworkVersion32=v4.0.30319
        @SET Framework40Version=v4.0
        @SET WindowsSdkDir=%ProgramFiles(x86)%\Windows Kits\8.1\
        @SET ExtensionSdkDir=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v8.1\ExtensionsSDKs\
        @SET WindowsSDK_ExecutablePath_x86=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\
        @SET WindowsSDK_ExecutablePath_x64=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\x64\
    

    也许,您需要稍微调整一些配置路径。

    有关更多信息,请参见此处:

    关于c++ - Visual Studio 2017 for Dymola无法打开stdio.h,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/55922093/

    10-09 17:02