Path Length Issues on Windows

The Windows API, by default, has a Maximum Path Length Limitation of 260 characters. This limitation can cause problems when building SimpleITK using the Superbuild process.

For this reason we recommend placing SimpleITK’s source and build directories at the top of the file system. For example, place the source code in C:SimpleITK and set the build directory to be C:SimpleITK-build.

Trying to build SimpleITK with too long a path length will result in an error like so:

 CMake Error at CMakeLists.txt:109 (message):
   -- Configuring incomplete, errors occurred!
   See also "C:/Users/dchen/VeryVeryLongPathName/SimpleITK-build/ITK-build/CMakeFiles/CMakeOutput.log".
     ITK source code directory path length is too long (55 > 50).Please move the
     ITK source code directory to a directory with a shorter path.

 C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(238,5): error MSB8066: C
 ustom build for 'C:\Users\dchen\VeryVeryLongPathName\SimpleITK-build\CMakeFiles\49f9d16effa529c310c9be3182f62407\ITK-mkdir.rule;C:\Users\dch
 \ff9535a930f370e2434114c6e547ebba\ITK.rule' exited with code 1. [C:\Users\dchen\VeryVeryLongPathName\SimpleITK-build\ITK.vcxproj]

Building SimpleITK with long path names

If SimpleITK must be built with long path names, two things need to be done:

  1. Enable Long Paths in Windows 10, Version 1607, and Later

  2. Set the ITK_SKIP_PATH_LENGTH_CHECKS cmake variable to ON in the External_ITK.cmake

Enabling Long Paths in Windows

As described in Microsoft’s documentation, Long path names are enabled in Windows by editing the registry with the following PowerShell command:

New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" `-Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force

The LongPathsEnabled property can also be edited using the Registry Editor app.


Next ITK needs to be configured so that it does NOT check path lengths in the build process. To disable the path length check, we simply need to add the entry ITK_SKIP_PATH_LENGTH_CHECKS to the CMake configuration, and set its value to ON. We can do this in the CMake GUI when we configure our SimpleITK SuperBuild.

After the initial configuration of the build, click on the “Add Entry” button, enter ITK_SKIP_PATH_LENGTH_CHECKS for the name, and click the Value checkbox to turn set the entry to ON.


Now we can build ITK within the SimpleITK SuperBuild with long path names.