问题
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). But when i try to test compiler in Dymola, I get an error message as follows :
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.
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. But its located in a separeate folder WindowsSDK in program files.
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)
回答1:
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. There are 2 possibilities:
- Get access to the registry from the IT.
- 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.
Here is the solution how to change the paths at least for 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. There you need to comment out the first 3 lines, which perform the not possible registry call that sets several paths. Afterwards, you need to set those paths manually in the vcvars32.bat
. Finally, the beginning of the vcvars32.bat
should look like this:
:: @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
回答2:
How have you verified that you have installed everything for C++-compilation?
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).
(Depending on version and configuration by administrators.)
回答3:
Ok, so turns out, even though I had admin rights, the IT dept didnt actually give me the ability to access registry i.e. regedit and it was just disabled.
So, after getting it enabled, I can confirm that now Dymola works fine with VS 2017 as well as 2015.
And apparently dymola needs to access regedit for compiling (not sure why).
来源:https://stackoverflow.com/questions/55922093/visual-studio-2017-for-dymola-cannot-open-stdio-h