简体   繁体   English

Visual Studio 2017 for Dymola 无法打开 stdio.h

[英]Visual Studio 2017 for Dymola cannot open stdio.h

I am trying to use Visual Studio 2017 as a compiler in Dymola 2019. I have installed all the components in VS2017 for C++ (as far as i could find).我正在尝试将 Visual Studio 2017 用作 Dymola 2019 中的编译器。我已经在 VS2017 中为 C++ 安装了所有组件(据我所知)。 But when i try to test compiler in Dymola, I get an error message as follows:但是当我尝试在 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. 

I also tried with Visual Studio 2015, but it failed as well.我也尝试过使用 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.

I also couldnt find stdio.h in the VS2017 folder anywhere.我也无法在任何地方的 VS2017 文件夹中找到 stdio.h。 But its located in a separeate folder WindowsSDK in program files.但它位于程序文件中的单独文件夹 WindowsSDK 中。

The compiler test should work (at least from my past experience with dymola and VS, not sure if something got messed up with the newer versions of these tools)编译器测试应该有效(至少根据我过去使用 dymola 和 VS 的经验,不确定这些工具的新版本是否有问题)

How have you verified that you have installed everything for C++-compilation?你如何验证你已经为 C++ 编译安装了所有东西?

For some configurations of Visual Studio you have to compile a C/C++ file to trigger download of the actual compiler (only the IDE is installed normally).对于 Visual Studio 的某些配置,您必须编译 C/C++ 文件才能触发实际编译器的下载(通常仅安装 IDE)。

(Depending on version and configuration by administrators.) (取决于管理员的版本和配置。)

Ok, so turns out, even though I had admin rights, the IT dept didnt actually give me the ability to access registry ie regedit and it was just disabled.好吧,事实证明,即使我有管理员权限,IT 部门实际上并没有给我访问注册表的能力,即 regedit,它只是被禁用了。

So, after getting it enabled, I can confirm that now Dymola works fine with VS 2017 as well as 2015.因此,在启用它之后,我可以确认 Dymola 现在可以在 VS 2017 和 2015 中正常工作。

And apparently dymola needs to access regedit for compiling (not sure why).显然 dymola 需要访问 regedit 进行编译(不知道为什么)。

Just to complete this as I also had the problem that I had the admin rights, but no access to the registry, so that Dymola threw the compiler error.只是为了完成这个,因为我也遇到了我拥有管理员权限但无法访问注册表的问题,因此 Dymola 引发了编译器错误。 There are 2 possibilities:有两种可能性:

  1. Get access to the registry from the IT.从 IT 获得对注册表的访问权限。
  2. If this is not possible, due to ristrictions.如果这是不可能的,由于限制。 Eiter install a tool that bypass the registry or change the paths manually, which I would recommand, as the tools are not so serious. Eiter 安装一个绕过注册表或手动更改路径的工具,我会推荐,因为这些工具不是那么严肃。

Here is the solution how to change the paths at least for VS2013.这是至少为 VS2013 更改路径的解决方案。 First of all, you need to open the vcvars32.bat from %ProgramFiles(x86)%\Microsoft Visual Studio 12.0\VC\bin\ in a texteditor that you have opened as admin.首先,您需要在以管理员身份打开的文本编辑器中从%ProgramFiles(x86)%\Microsoft Visual Studio 12.0\VC\bin\打开vcvars32.bat There you need to comment out the first 3 lines, which perform the not possible registry call that sets several paths.在那里您需要注释掉前 3 行,它们执行设置多个路径的不可能的注册表调用。 Afterwards, you need to set those paths manually in the vcvars32.bat .之后,您需要在vcvars32.bat中手动设置这些路径。 Finally, the beginning of the vcvars32.bat should look like this:最后, 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\

Perhaps, you need to slightly adapt some paths for your configuration.也许,您需要为您的配置稍微调整一些路径。

For more information you can look here:有关更多信息,您可以在此处查看:

VS2010 command prompt gives error: Cannot determine the location of the VS Common Tools folder VS2010命令提示报错:Cannot determine the location of the VS Common Tools folder

Different reasons may cause it.不同的原因可能会导致它。

You might catch up with the issue if you deleted the PATH value in the system environment variables by accident before installing Dymola.如果在安装 Dymola 之前不小心删除了系统环境变量中的 PATH 值,则可能会遇到此问题。 After adding "%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0" into the PATH value in the system environment variables, the compiler can work again.将“%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0”添加到系统环境变量中的PATH值后,编译器又可以工作了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM