mosra / magnum-bootstrap

Bootstrap projects for the Magnum C++11 graphics engine
https://magnum.graphics/
The Unlicense
92 stars 37 forks source link

Building Issue - The fully qualified file name must be less than 260 characters #28

Closed kai17kai closed 2 years ago

kai17kai commented 2 years ago

I just started using the magnum library on a Windows computer. I was following the Get Started tutorial and was able to finish it. I then went to the Triangle example. I followed the tutorial and started to build the project. The build then comes with this error.

_C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(382,5): error MSB3491: Could not write lines to file "x64\Debug\MagnumShaders_RESOURCES_GL-dependencies\MagnumSh.9D2F43E4.tlog\MagnumShaders_RESOURCES_GL-dependencies.lastbuildstate". Path: x64\Debug\MagnumShaders_RESOURCES_GL-dependencies\MagnumSh.9D2F43E4.tlog\MagnumShaders_RESOURCESGL-dependencies.lastbuildstate exceeds the OS max path limit. The fully qualified file name must be less than 260 characters.

All the other parts of the build succeeded and I was even able to run the application. From what I understand about this error is that it is a well-known restriction within the Win32 API. Is there a way to get around this error?

mosra commented 2 years ago

Hi!

Heh, I thought this ancient curse was a solved problem for a long time already, but apparently msbuild is still stuck in the stone age :laughing:

One of the usual solutions is to put the project in some shorter path (say, C:/magnum instead of C:/Users/Me Myself The First/Projects/Coding/C++/Playground/Experimental Temporary Projects/Magnum Graphics Engine/magnum-bootstrap). Another option (which is probably cleaner) is to use the subst command, let's say:

subst Z: C:/Users/Me Myself The First/Projects/Coding/C++/Playground/Experimental Temporary Projects/Magnum Graphics Engine/magnum-bootstrap

(Or maybe it requires backward slashes?) And then open the project through Z: instead of the original path. A downside is that you'd have to do this every time you restart the computer, which is quite annoying.

The third suggestion (or rather a non-suggestion) is to not use msbuild, but I'm not sure if Visual Studio is able to work with tools like ninja -- you may then need to switch to another IDE altogether (VS Code, ...).