Simulink model can be compiled in normal mode, but can't be compiled in acceleration mode?

6 ビュー (過去 30 日間)
Rui Zhang
Rui Zhang 2021 年 5 月 21 日
回答済み: Shiva Kalyan Diwakaruni 2021 年 5 月 24 日
I removed all the C-code in S-functions in my Simulink model and I want to run it in acceleration mode. I am able to run it in normal mode with MS VC++ 2015 and MATLAB 2017b.
Below is the message that I got when compiling in acceleration mode:
Error in script usage. The correct usage is: "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\VCVARSALL.BAT " [option] or "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\VCVARSALL.BAT " [option] store or "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\VCVARSALL.BAT " [option] [version number] or "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\VCVARSALL.BAT " [option] store [version number] where [option] is: x86 | amd64 | arm | x86_amd64 | x86_arm | amd64_x86 | amd64_arm where [version number] is either the full Windows 10 SDK version number or "8.1" to use the windows 8.1 SDK : The store parameter sets environment variables to support store (rather than desktop) development. : For example: "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\VCVARSALL.BAT " x86_amd64 "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\VCVARSALL.BAT " x86_arm store "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\VCVARSALL.BAT " x86_amd64 10.0.10240.0 "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\VCVARSALL.BAT " x86_arm store 10.0.10240.0 "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\VCVARSALL.BAT " x64 8.1 "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\VCVARSALL.BAT " x64 store 8.1 : Please make sure either Visual Studio or C++ Build SKU is installed. 'nmake' is not recognized as an internal or external command, operable program or batch file. The make command returned an error of 9009 'An_error_occurred_during_the_call_to_make' is not recognized as an internal or external command, operable program or batch file.

回答 (1 件)

Shiva Kalyan Diwakaruni
Shiva Kalyan Diwakaruni 2021 年 5 月 24 日
Hi,
1.The problem might be due to the following lines in the makefile. The .mk file might contains the following code:
MATLAB_ROOT = C:\Program Files\MATLAB\R2017b
ALT_MATLAB_ROOT = C:\Program Files\MATLAB\R2017b
MATLAB_BIN = C:\Program Files\MATLAB\R2017b\bin
ALT_MATLAB_BIN = C:\Program Files\MATLAB\R2017b\bin
Since the MATLAB_ROOT and ALT_MATLAB_ROOT variables have the same value, the makefile was using the MATLAB_ROOT value with spaces. The build process does not know how to handle files with spaces in the path. MATLAB normally populates ALT_MATLAB_ROOT with the short path name, usually "C:\PROGRA~1". However, on some Windows systems generation of short path names may be disabled. Also, if MATLAB was itself installed in a path with a space in it (such as C:\Program Files) in the R2015a SP1 update and later releases, the issue was fixed and would not occur.
The proper code should have been as below:
MATLAB_ROOT = C:\Program Files\MATLAB\R2017b
ALT_MATLAB_ROOT = C:\PROGRA~1\MATLAB\R2017b
MATLAB_BIN = C:\Program Files\MATLAB\R2017b\bin
ALT_MATLAB_BIN = C:\PROGRA~1\MATLAB\R2017b\bin
There are a few methods for resolving this issue.
  • SOLUTION 1 - Using Windows short names:
This is perhaps the easiest of the solutions. There is a setting in Windows registry that enables/disables the generation of short names for file paths. Please use the following steps to change this setting:
(NOTE: Due to Windows security settings on the Program Files folder, this method may not work. If you receive a message during step 4 that says "Error: Access is denied.", please use one of the other solutions.)
1. Go to Windows Start menu and search for "regedit.exe". A new window will open.
2. Navigate to the following location:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem\NtfsDisable8dot3NameCreation
3. Change the value of "NtfsDisable8dot3NameCreation" to 0.
Changing the value to 0 will enable the usage of short names in Windows paths. More information about this could be found at Microsoft's website:
4. However, changing the value above will only set short names files and folders that are created after making the change. To set a short name for use the "fsutil" function in Windows command prompt. The syntax to set the short name is as follows:
> fsutil file setshortname <FileName> <ShortName>
For the example of "C:\Program Files" the user would issue the following command to set the short name for "Program Files" to "PROGRA~1".
> fsutil file setshortname "C:\Program Files" PROGRA~1
The directory needs to be in quotations because it has spaces.
5. To check that the short name was set correctly use the "dir" command with "/x" option to show short names.
> dir C:\ /x
More information for "fsutil" can be found here:
  • SOLUTION 2 - Create a symbolic link to the MATLAB installation folder:
1. Open a Windows Command Prompt. And go to the C: directory.
2. Create the symbolic link to the location that your MATLAB versions are installed. The syntax is as follows:
> mklink /d <Link> <Target>
For example, a typical MATLAB installation folder is C:\Program Files\MATLAB. To make a link to that folder called MyMatlab use the following command:
> mklink /d C:MyMatlab "C:\Program Files\MATLAB"
If you open the new MyMatlab folder, you should see the folders for each version of MATLAB that are installed.
3. Create a new shortcut for MATLAB. This can go on your desktop or wherever you would like.
4. Right click on the shortcut and open Properties.
5. Go to the 'Shortcut' tab. In the 'Target:' option there will be a path to the executable that is used to launch MATLAB from this shortcut. Modify this path to use the newly created symbolic link. For the example above the, it should read
C:\MyMatlab\R2017b\bin\matlab.exe
6. Launch MATLAB from this shortcut. Verify the location by typing "matlabroot" without quotations in Command Window, this should have no spaces in it now.
7. If you have multiple versions of MATLAB, repeat steps 3-6 for each version so that they will be launched from a location with no spaces in the path.
This solution will work for the newly created shortcuts. If you launch MATLAB from a different location it will not use the symbolic link and there will be the same issue with spaces in the path.
  • SOLUTION 3 - Change the MATLAB Installation Folder:
The reason we use short path is to avoid white spaces in the paths. By reinstalling MATLAB at a location without any spaces in the paths, you can workaround the build issue. However, this will require you to download and reinstall MATLAB.
For example, MATLAB can be installed at a path as below
C:\MATLAB_Install\MATLAB\R2017b
Much like Solution 2, this solution will require you to reinstall MATLAB for all versions that you use.
  • SOLUTION 4 - Modify the template makefile
Another way around this issue is to encase the file names in double quotes. This will cause the build process to treat the file names enclosed in double quotes literally which will cause the build to succeed.
To do this, open the template makefile that you are using for code generation. Make a copy of this file and rename it. Inside this file, wherever "$(MATLAB_ROOT)" is used as part of a path, put a double quote before the "$" sign and after the last character in the path. For example, if the original line in the TMF was:
{$(MATLAB_ROOT)\toolbox\rtw\targets\xpc\target\build\xpcblocks}.c.obj :
The line would be replaced with:
{"$(MATLAB_ROOT)\toolbox\rtw_targets\xpc\target\build\xpcblocks"}.c.obj :
In "Configuration Parameters" -> "Code Generation" make sure that the "Template makefile" option points to the modified TMF, or else the changes will not be reflected in the generated code.
This method will need to be repeated for each template makefiles that is used.
A useful documentation page for MATLAB R2017a discussing the methods of enabling build processes for folder name with spaces can be found at the following link:
The limitations mentioned in the section 'Build Process Folder Support on Windows' are addressed in the methods mentioned above.
2. if the above solution did not work the error might have occured because of order of instllation.
The order of installation of Microsoft Visual Studio 2010 and Microsoft Windows SDK 7.1 matters. Confirm if ‘Microsoft Visual C++ 2010’ was installed BEFORE ‘Microsoft Windows SDK 7.1’. This is important to follow because ‘Microsoft Windows SDK 7.1’ changes the compiler file settings while it installs.
If Microsoft Windows SDK 7.1 was installed first, it is recommended to uninstall ‘Microsoft Visual C++ 2015 and ‘Microsoft Windows SDK 8.1 and install in the following order
1.Microsoft Visual Studio C++ 2015
2.Microsoft Windows SDK 8.1
Refer to the following solution link for detailed steps on how to go about the installation:
Hope it helps

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by