Clear Filters
Clear Filters

Why is the build process failing with error code: "NMAKE: fatal error U1073: don't know how to make 'C:\Program'"?

141 views (last 30 days)
When I try to build a built-in model, I get an error message stating that the build has failed. I have a supported Microsoft C/C++ compiler (Windows SDK/Visual Studio) installed and properly set up.
The error message will look similar to the following:
ERROR: NMAKE : fatal error U1073: don't know how to make 'C:\Program'
The make command returned an error of 2
'An_error_occurred_during_the_call_to_make' is not recognized as an internal or external command,
operable program or batch file.
A similar error may occur in the build log for models that are run in Accelerator mode, or when building the model for Simulink Coder, Embedded Coder, or Simulink Real-Time.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 1 Sep 2022
Edited: MathWorks Support Team on 1 Sep 2022
The problem with the build process is due to the following lines in the "" makefile. The .mk file contains the following code:
MATLAB_ROOT     = C:\Program Files\MATLAB\R2013a
ALT_MATLAB_ROOT = C:\Program Files\MATLAB\R2013a
MATLAB_BIN      = C:\Program Files\MATLAB\R2013a\bin
ALT_MATLAB_BIN  = C:\Program Files\MATLAB\R2013a\bin
Since the MATLAB_ROOT and ALT_MATLAB_ROOT variables have the same value, the makefile is 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". This issue may occur:
(1) If the generation of short path names is disabled on your Windows system.
(2) If MATLAB was itself installed in a path with a space in it (such as C:\Program Files) for R2014b and earlier. In the R2015a SP1 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\R2013a
MATLAB_BIN = C:\Program Files\MATLAB\R2013a\bin
There are a few methods for resolving this issue:

SOLUTION 1 - Enable 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:
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 for 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 where 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
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 paths 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
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 makefile that is used.
A useful documentation page for MATLAB R2017a discussing the methods of enabling build processes for folder names 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. 

More Answers (0)


Find more on Introduction to Installation and Licensing in Help Center and File Exchange


Community Treasure Hunt

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

Start Hunting!