Build Process Support for File and Folder Names
Filenames with Spaces
For the build process that uses ToolchainInfo
objects, only these
toolchains support the use of filenames containing spaces:
GNU gcc/g++ | gmake (64-bit Linux)
on Linux®MinGW64 | gmake (64-bit Windows)
on Windows®Xcode with Clang | gmake (64-bit Mac)
on Mac
The build process that uses template makefiles does not support the use of filenames containing spaces.
Folder Names with Spaces
On a Windows system, the code generator maps a drive corresponding to the MATLAB® installation folder for either of these conditions:
The
matlabroot
folder is a UNC location.The path the
matlabroot
folder contains spaces, and the system has no alternative name support.
These folder paths can contain spaces:
The path to your MATLAB installation folder (
matlabroot
). For example,C:\Program Files\MATLAB\R2015b
The path to the current working folder where you start the build (
pwd
). For example,C:\Users\username\Documents\My Work
.The path to the installation folder for a compiler that the build process uses.
If your work environment includes one or more of the preceding scenarios, use the following support mechanisms for the build process:
If you are using the toolchain approach to build generated code, the system support for spaces in folder names influences toolchain operation:
For Linux systems and Windows systems with 8.3 name creation enabled, the toolchain manages spaces in folder names by using alternative names from the operating system. The toolchain uses the
TransformPathsWithSpaces
attribute to manage these names.addAttribute(toolchainObject, 'TransformPathsWithSpaces', true);
The security permissions of drives and folders can determine whether the toolchain transforms the path. For example, if the path contains a folder with a security configuration that forbids 8.3 path transformations, the toolchain does not transform the path and the build process produces a warning.
For Windows systems with 8.3 name creation disabled, the toolchain manages spaces in folder names by mapping a network drive using a batch file (.bat). This operation requires adding the
RequiresBatchFile
attribute to the toolchain definition.addAttribute(toolchainObject, 'RequiresBatchFile', true);
When developing a toolchain for a Windows system, set both attributes. For more information about the toolchain attributes, see
addAttribute
.If you are using the template makefile approach to build generated code, the template makefile (
.tmf
) requires code to manage spaces in folder names. When the alternative folder names (Windows short names) differ from the file system folder names (Windows long names), add this code to the makefile.ALT_MATLAB_ROOT = |>ALT_MATLAB_ROOT<| ALT_MATLAB_BIN = |>ALT_MATLAB_BIN<| !if "$(MATLAB_ROOT)" != "$(ALT_MATLAB_ROOT)" MATLAB_ROOT = $(ALT_MATLAB_ROOT) !endif !if "$(MATLAB_BIN)" != "$(ALT_MATLAB_BIN)" MATLAB_BIN = $(ALT_MATLAB_BIN) !endif
When the values of the location tokens are not equal, this code replaces
MATLAB_ROOT
withALT_MATLAB_ROOT
. The replacement indicates that the path to your MATLAB installation folder includes spaces. This code applies the same type of replacement forMATLAB_BIN
withALT_MATLAB_BIN
. The preceding code is specific tonmake
. For platform-specific examples, see the supplied template makefiles.
With either build approach, when there is an issue with support for creation of alternate names (short names), build errors can occur on Windows. If a build generates an error message similar to the following message, see Troubleshooting Errors When Folder Names Have Spaces.
NMAKE : fatal error U1073: don't know how to make ' ...
When using operating system commands, such as system
or dos
, enclose paths that specify executable files or command parameters in double quotes (" "
). For example:
system('dir "D:\Applications\Common Files"')
This table provides a summary of build folder support and limitations for Windows.
Build Process Folders | Approach for Paths with UNC or Spaces | Support for Windows |
---|---|---|
The
| During a build, a UNC location such as:
could be remapped as:
During
a build on a Windows system with short filename (8.3) support (default for
Windows using NTFS), the build process uses the Windows API
During a build on a Windows system without short filename (8.3) support (systems using ReFS or using NTFS with 8.3 support disabled), a location with spaces in the path such as:
could be remapped as:
| Build process folder support available independent of file system (NTFS or ReFS) or file system configuration for short filename support. Limitations: On systems that require drive mapping for the installation location, the build process requires that a drive letter is available for mapping. On systems without short filename (8.3) support (using ReFS or using NTFS with 8.3 support disabled), the final folder in the installation location cannot contain spaces. For example, a final folder name:
is not supported. |
Code generation folder Simulation cache folder Custom code source file locations—among others, these locations include folders specified by:
| For UNC locations, build process temporarily maps a drive by
using the shell commands | Build process folder support is available independent of file system (NTFS or ReFS) or file system configuration for short path name support. |
For paths with spaces, build process uses the Windows short path name (8.3) by using the Windows API:
| Build process folder support depends on NTFS file system and requires Windows default support. Registry sets value of 2 or 0 for:
Limitations: Build process does not support spaces in the path to these folders for:
|
Troubleshooting Errors When Folder Names Have Spaces
On Windows, when there is an issue with support for creation of short filenames, build process errors can occur. When this issue affects a build, you see an error message similar to:
NMAKE : fatal error U1073: don't know how to make 'C:\Work\My'
This message can occur if a space in the folder name
(C:\Work\My Models
) prevents the build process from finding the
model or a file to build. For descriptions of the build-related folders that are
sensitive to a space in the folder name or path, see Folder Names with Spaces.
To avoid issues from folder names with spaces when Windows short filename support for filenames is disabled, do not use paths with spaces. For example, install third-party software to paths without spaces. Do not use paths with spaces for folders containing your models, source files, or libraries.
An issue can occur with builds that use folder names with spaces, because it is possible to disable Windows alternate name support. The build process uses this alternate name support on Windows systems. There are many terms for this file, folder, and path alternate name support:
8.3 name
DOS path
short filename (SFN, ShortFileName)
long name alias
Windows path alias
Verify the type of file system that the drive uses. In Windows Explorer, right-click the drive icon and select properties.
If the file system is ReFS (Resilient File System), it is an issue. The ReFS does not provide short filename support. Except for the MATLAB installation folder, the build process does not support folder names with spaces for the ReFS file system. If your work environment requires short filename support for the build folder or for additional external code folders, do not use ReFS.
If the file system is NTFS (New Technology File System), it is possible that the build error is related to a registry setting incompatibility. Continue with troubleshooting steps.
The error could stem from an issue with short filename support on a system using NTFS. Check the Windows registry setting that enables the creation of short names for files, folders, and paths.
Open the Windows command prompt, running as administrator. For example, from the Windows Start menu, type
cmd
, right-click thecmd.exe
icon, and selectRun as administrator
.Change to the
windows\system32
folder and query theNtfsDisable8dot3NameCreation
status by typing:> fsutil 8dot3name query
If the registry state of
NtfsDisable8dot3NameCreation
is not 0 (enable8dot3
name creation for all volumes on the system), change the value to 0 by typing:> fsutil 8dot3name set 0
For more information about enabling creation of short names. See https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-R2-and-2012/ff621566(v=ws.11).
Changing the registry setting enables creation of short names only for files and folders that are created after the change.
To create short names for files created while short name creation was disabled, at the Windows command line, use the
fsutil
utility.To set the short name, the syntax is:
> fsutil file setshortname <FileName> <ShortName>
For example, to create the short name
PROGRA~1
for the long nameC:\Program Files
, type:> fsutil file setshortname "C:\Program Files" PROGRA~1
The
C:\Program Files
folder name is in quotations because it has spaces.To verify that the short name was created, use the
dir
command with/x
option to show short names.> dir C:\ /x
Folder Names with Special Characters
The build process might produce an error if a build-related folder path contains:
Unicode® characters that do not belong to the system locale. This limitation does not apply if the build process uses a Microsoft® Visual C++® compiler.
A Japanese (multibyte) character where the final byte is equal to the
5C
hexadecimal character. The make and compiler tools might incorrectly interpret the final byte as the'\'
(backslash) character.One or more of these characters:
'&'
(ampersand)':'
(colon)';'
(semicolon)'$'
(dollar sign)'('
(left parenthesis)')'
(right parenthesis)'^'
(circumflex accent)
Very Long Folder Paths
For the MinGW® compiler, the build process produces an error when the command line length exceeds the Windows limit of 32,767 characters. If this error occurs, check the length of include paths. You can reduce the command line length by building the generated code in a code generation folder that has a shorter name
See Also
Related Topics
- Manage Build Process Folders
- Manage Build Process Files
- Manage Build Process File Dependencies
- Add Build Process Dependencies
- Build Process Workflow for Real-Time Systems
External Websites
- https://www.mathworks.com/matlabcentral/answers/95399-why-is-the-build-process-failing-with-error-code-nmake-fatal-error-u1073-don-t-know-how-to-make
- https://learn.microsoft.com/previous-versions/windows/it-pro/windows-2000-server/cc959352(v=technet.10)
- https://learn.microsoft.com/previous-versions/windows/it-pro/windows-server-2012-R2-and-2012/ff621566(v=ws.11)