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:
matlabrootfolder is a UNC location.
The path the
matlabrootfolder 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,
The path to the current working folder where you start the build (
pwd). For example,
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
TransformPathsWithSpacesattribute 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
RequiresBatchFileattribute 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
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
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|
During a build, a UNC location such as:
could be remapped as:
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.
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
Custom code source file locations—among others, these locations include folders specified by a Code Replacement Library
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 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:
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 the
cmd.exeicon, and select
Run as administrator.
Change to the
windows\system32folder and query the
NtfsDisable8dot3NameCreationstatus by typing:
> fsutil 8dot3name query
If the registry state of
NtfsDisable8dot3NameCreationis not 0 (enable
8dot3name 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
To set the short name, the syntax is:
> fsutil file setshortname <FileName> <ShortName>
For example, to create the short name
PROGRA~1for the long name
C:\Program Files, type:
> fsutil file setshortname "C:\Program Files" PROGRA~1
C:\Program Filesfolder name is in quotations because it has spaces.
To verify that the short name was created, use the
/xoption 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
5Chexadecimal character. The make and compiler tools might incorrectly interpret the final byte as the
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