Linux 的 Windows 子系统中缺少 C 和 C++ 编译器

Missing C & C++ compilers in Windows Subsystem for Linux

我正在尝试使用 Windows 子系统为 Linux (Windows 10 build 10.0.14342) 编译 LLVM,但我不断收到关于我如何运行的 cmake 错误缺少 C 和 C++ 编译器。尽管通过使用 bash 中的 apt-get 获得了 gcc、g++ 和 build-essentials,但还是如此。我的命令如下:

cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="X86" ../llvm-3.8

我从 CMake 收到一堆错误

CMake Error: Parse error in cache file /home/andrew-wsl/llvm/build/CMakeCache.txt. 
Offending entry: Debug Info builds.
CMake Error: Parse error in cache file /home/andrew-wsl/llvm/build/CMakeCache.txt. 
Offending entry: CMAKE_MODULE_LINKER_FLAGS_RELEASE-ADVANCED
-- The C compiler identification is unknown
CMake Error at /usr/share/cmake-2.8/Modules/CMakeDetermineCCompiler.cmake:186 (configure_file):
  configure_file Problem configuring file
Call Stack (most recent call first):
  CMakeLists.txt:54 (project)


-- The CXX compiler identification is unknown
CMake Error at /usr/share/cmake-2.8/Modules/CMakeDetermineCXXCompiler.cmake:185 (configure_file):
  configure_file Problem configuring file
Call Stack (most recent call first):
  CMakeLists.txt:54 (project)


-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc
CMake Error at /usr/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:47 (try_compile):
  Unknown extension ".c" for file

    /home/andrew-wsl/llvm/build/CMakeFiles/CMakeTmp/testCCompiler.c

  try_compile() works only for enabled languages.  Currently these are:

    ASM C CXX

  See project() command to enable other languages.
Call Stack (most recent call first):
  CMakeLists.txt:54 (project)


-- Check for working C compiler: /usr/bin/cc -- broken
CMake Error at /usr/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:61 (message):
  The C compiler "/usr/bin/cc" is not able to compile a simple test program.

  It fails with the following output:





  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:54 (project)


-- Configuring incomplete, errors occurred!
See also "/home/andrew-wsl/llvm/build/CMakeFiles/CMakeOutput.log".
See also "/home/andrew-wsl/llvm/build/CMakeFiles/CMakeError.log".
andrew-wsl@COMPUTER:~/llvm/build$

CMakeError.log 可以在这里找到:http://pastebin.com/7rWYFGu5

CMakeOutput.log 可以在这里找到:http://pastebin.com/2BaEFTvR

我不确定发生了什么,因为我能够成功地使用 gcc 和 g++ 编译 helloworld 程序。

原来这是一个已知错误:https://github.com/Microsoft/BashOnWindows/issues/272

长话短说,自 build 14352 起已修复。