Hauptinhalt

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.

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 FoldersApproach for Paths with UNC or SpacesSupport for Windows

matlabroot folder

The matlabroot value is derived from the MATLAB installation location.

During a build, a UNC location such as:

\\networkdrive\matlab\R20xxb

could be remapped as:

T:\

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 getShortPathName() for the folder location.

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:

C:\Program Files\MATLAB\R20xxb

could be remapped as:

T:\R20xxb

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:

C:\Program Files\MATLAB\R20xxb sp1

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 pushd and popd.

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:

getShortPathName()

Build process folder support depends on NTFS file system and requires Windows default support. Registry sets value of 2 or 0 for:

NtfsDisable8dot3NameCreation

Limitations: Build process does not support spaces in the path to these folders for:

  • NTFS file system with short path name support disabled

  • ReFS file system (this file system does not support short path names)

Troubleshooting Errors When Folder Names Have Spaces

On Windows, when there is an issue with short filename support, build process errors can occur. You might see an error message like this:

NMAKE : fatal error U1073: don't know how to make 'C:\Work\My'

The error occurs 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 folder name space issues when Windows short filename support is disabled, do not use folder paths that contain spaces, for example:

  • For folders where you install third-party software.

  • For folders that contain your models, source files, or libraries.

The build process uses alternate name support for files, folders, and paths on Windows systems. There are various terms for alternate name support:

  • 8.3 name

  • DOS path

  • short filename (SFN, ShortFileName)

  • long name alias

  • Windows path alias

An issue can occur with builds that use folder names with spaces because it is possible to disable Windows alternate name support.

Determine 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), the file system does not provide short filename support. Except for the MATLAB installation folder, the build process does not support folder names with spaces. If your work environment requires short filename support for the build folder or additional external code folders, do not use ReFS.

  • If the file system is NTFS (New Technology File System), the build issue might be related to a Windows registry setting incompatibility.

To manage the Windows registry setting that enables the creation of short names for files, folders, and paths:

  1. Open the Windows Command Prompt, running as administrator. For example, from the Windows Start menu, type cmd, right-click the cmd.exe icon, and select Run as administrator.

  2. Go to the Windows\System32 folder and query the NtfsDisable8dot3NameCreation status by typing:

    fsutil 8dot3name query

    The registry state can have one of these values:

    • 0 — 8dot3 name creation enabled for all volumes on system

    • 1 — 8dot3 name creation disabled for all volumes on system

    • 2 — Can set 8dot3 name creation on a per volume basis

    • 3 — 8dot3 name creation disabled for all volumes except the system volume

  3. Suppose the registry state of NtfsDisable8dot3NameCreation is 2. You can enable 8dot3 name creation for a specific drive, say D, by typing:

    fsutil 8dot3name set D: 0

    Then reboot the computer. Changing the registry setting enables creation of short names only for files and folders that are created after the change.

    For more information about enabling short name creation, see https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/fsutil-8dot3name .

To create a short name for a file created previously while short name creation was disabled, use this command:

fsutil file setshortname fileName shortName

For example, to create the short name PROGRA~1 for the long name C:\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 is 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

External Websites