Simcenter Amesim How can I use the Microsoft Visual C++ 2019 compiler in Simcenter Amesim?

2024-05-14T14:01:26.000-0400
Simcenter Amesim Automation Connect Simcenter System Simulation Client for Git Simcenter Amesim Teamcenter Share

Summary

This article describes shortly how to set up your machine to be able to use the Microsoft Visual C++ 2019 compiler in Simcenter Amesim.


Details

Error Message

Have you ever encountered  the following error message when trying to compile your Simcenter Amesim model with the Microsoft Visual C++ 2019 compiler, referring to "'nmake' is not recognized as an internal or external command, operable program or batch file."? 

Error message when compilation with Microsoft Visual C++ 2019 compiler fails

Then this article can help you to resolve your issue.

Prerequisite

The important prerequisite is that you have the Microsoft Visual C++ 2019 compiler installed on your machine. In this article, an installation of Microsoft Visual Studio 2019 Professional is used to provide the needed Visual C++ 2019 compiler. Please contact your IT department to install the according compiler.

Set up in Simcenter Amesim

Generally, there are two possibilities to set up your machine, so that Simcenter Amesim is able to use the Microsoft Visual C++ 2019 compiler. These will be outlined in the next two subsections.

1.) Defining environment variable VS160COMNTOOLS

In the simplest case, after installing Microsoft Visual Studio 2019 Professional, you need to define an environment variable 'VS160COMNTOOLS' pointing to the 'Tools' subfolder in the 'Common' folder of your Microsoft Visual Studio 2019 Professional installation folder, e.g.:

Definition of the environment variable VS160COMNTOOLS for Microsoft Visual C++ 2019 compiler

This step is important, since Simcenter Amesim (up to version 2404) is using this environment variable (or better the according path) in the "vcvars64_vc140.bat" file (located in the Simcenter Amesim installation folder) to call the "vcvarsall.bat" file (located in another subfolder dedicated to the Visual C++ compiler in the Microsoft Visual Studio 2019 installation folder) with the 64-bit option to initiate the compilation with the Microsoft Visual C++ 2019 compiler (64-bit):

Initiate compilation with Microsoft Visual C++ 2019 call through vcvars64_vc140.bat file

2.) Adapting the "vcvars64_vc140.bat" file

If you do not want to define the environment variable 'VS160COMNTOOLS', you can directly set the path to call the needed "vcvarsall.bat" file in the "vcvars64_vc140.bat" file located in your Simcenter Amesim installation folder. For this purpose, please open the "vcvars64_vc140.bat" with a text editor and change the according lines referring to the "Visual Studio 2019 compiler" as follows:

Adapting "vcvars64_vc140.bat" file

You can see in line 10 starting with the command 'call' that directly the according "vcvarsall.bat" with the option "x64" is called to initiate a compilation with the Microsoft Visual C++ 2019 (64-bit) compiler. Probably, you need to provide another path if your Microsoft Visual Studio 2019 Professional installation folder location differs from the one in the example. You can also adapt line 11 so that a success message is drawn in the Simcenter Amesim compilation window, when the compilation is done.

Following one of the above instructions, you can select and use the Microsoft Visual C++ 2019 (64-bit) compiler as the active compiler set in the "Compilation" tab of the Preferences window accessible via "Tools -> Preferences" in the Simcenter Amesim GUI:

Setting Microsoft Visual C++ 2019 compiler in Compilation tab of Preferences window

 

Remarks

If the "vcvars64_vc140.bat" is not present in your Simcenter Amesim installation folder, you can find a template file called "vcvars64_vc140_template.bat" in the 'misc' subfolder of your Simcenter Amesim installation folder:

Location of the "vcvars64_vc140_template.bat" file

Please copy this file into your Simcenter Amesim installation folder, rename it into "vcvars64_vc140.bat" and adapt it if needed.

 

If you need to set up the Intel oneAPI C++ compiler in Simcenter Amesim, please have a look into the article "How can I use the Intel oneAPI DPC++/C++ Compiler in Simcenter Amesim?". 

KB Article ID# KB000132427_EN_US

Contents

SummaryDetails

Associated Components

Amesim Automation Connect