简体   繁体   中英

How to handle long paths in cmd.exe

I am helping some developers create a Windows port of a Linux project where the source tree is extremely deep, total path lengths far exceeding 260 chars. At least for now, all that is needed is to run gcc compilations. The source code tree is shared Linux/Windows, and maintaine externally; modifying the tree structure or changing file names (eg to symlinks, or using subst to mount a subtree) are not viable alternatives.

To complicate it further: The builds will be made in a Docker container of Windows flavor. So solutions are limited to those that can run on a Windows docker base image.

I have set the HKLM\SYSTEM\CurrentControlSet\Control\FileSystem LongPathsEnabled value to 1, and I assume that if I create my own application, I could provide an Application Manifest with a true. But I am not creating gcc, so how can I tell the cmd.exe that gcc is not limited to 260 chars path length? (Setting the registry variable was not by itself sufficient!)

Will running gcc from cmd.exe require that cmd.exe can handle long pahts - and can it? Could I use another shell that can handle long paths (and that is not restricted by any underlaying cmd.exe?

Why not avoid cmd.exe altogether? Just use the MSYS2 shell ( https://www.msys2.org/ ).

This solved a lot porting issues, and in fact allows you to use the same build tools (autoconf and even cmake and meson).

I have used this environment on Windows for many years. In fact I built the latest GCC and MinGW-w64 entirely like this (see: http://winlibs.com/ ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM