Intermittent, random 'file not found' erro

2019-03-24 00:44发布

问题:

I'm getting intermitting 'fatal error: ... file not found' errors building C++ application using either gcc 4.8 or clang 3.8 under Ubuntu 16.04.2 running in Windows Subsystem for Linux (WSL), when including C++ header files, but only since installing the Windows 10 April update (Version 1803, OS Build 17134.1) a few days ago.

Example error message from clang compiler:

fatal error: 'boost/preprocessor/list/fold_left.hpp' file not found

Example error message from gcc compiler:

fatal error: boost/mpl/aux_/at_impl.hpp: No such file or directory

I say the error is intermittent because if I re-run the build, the particular error that interrupted the build disappears, and the build runs for a while longer until it either builds successfully or randomly fails to include some other file with the same kind of 'file not found' error.

The timing of this fault and the randomness of it make me suspect it is a new bug in WSL. Anyone else seeing this or have suggestions on how to fix it?

The error is not always in a Boost include, but often is simply because Boost comprises a large proportion of the overall include files. The files being built exist on a shared volume under /mnt/d/.

回答1:

This has been identified as a multithreading bug (https://docs.microsoft.com/en-us/windows/wsl/release-notes#build-17655-skip-ahead) and should get fixed in a future windows update.

Since it's a multithreading bug, it might be possible to work around it by not using multithreaded builds.

If in a hurry, it might be possible to just get to the windows insider program and use one of the preview builds.



回答2:

In my case, it was not multi-threading but the path to the toolchain. The failed case was: toolchain was installed in /mnt/c/.../tools/ A good case was: toolchain was installed in /home/yurir/tools/

I guess the mapping of windows folders with ubuntu folders creates some mess.