在 WSL 上对 configure_file 的每次调用都会失败:configure_file 配置文件有问题

Cia*_*lsh 5 c++ linux cmake windows-subsystem-for-linux

我刚刚在全新的 WSL 安装 (Ubuntu18.04 LTS) 上构建并安装了 cmake 3.16。然后我创建了一个默认的 hello world 项目

\n
(base) ciaran@DESKTOP-K0APGUV:/mnt/d/ATest$ tree .\n.\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 CMakeLists.txt\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 main.cpp\n
Run Code Online (Sandbox Code Playgroud)\n
//CMakeLists.txt\ncmake_minimum_required(VERSION 3.15)\nproject(ATest)\n\nset(CMAKE_CXX_STANDARD 14)\n\nadd_executable(ATest main.cpp)\n
Run Code Online (Sandbox Code Playgroud)\n
//main.cpp\n#include <iostream>\n\n#include <string>\n\nint main() {\n    std::cout << "Hello, World!" << std::endl;\n    return 0;\n}\n\n
Run Code Online (Sandbox Code Playgroud)\n

然后尝试构建:

\n
(base) ciaran@DESKTOP-K0APGUV:/mnt/d/ATest$ mkdir build\n(base) ciaran@DESKTOP-K0APGUV:/mnt/d/ATest$ cd build/\n(base) ciaran@DESKTOP-K0APGUV:/mnt/d/ATest/build$ cmake ..\n
Run Code Online (Sandbox Code Playgroud)\n

我得到以下信息。

\n
CMake Error at /usr/local/share/cmake-3.16/Modules/CMakeDetermineSystem.cmake:185 (configure_file):\n  configure_file Problem configuring file\nCall Stack (most recent call first):\n  CMakeLists.txt:2 (project)\n\n\n-- The C compiler identification is GNU 10.1.0\nCMake Error at /usr/local/share/cmake-3.16/Modules/CMakeDetermineCCompiler.cmake:212 (configure_file):\n  configure_file Problem configuring file\nCall Stack (most recent call first):\n  CMakeLists.txt:2 (project)\n\n\n-- The CXX compiler identification is GNU 10.1.0\nCMake Error at /usr/local/share/cmake-3.16/Modules/CMakeDetermineCXXCompiler.cmake:210 (configure_file):\n  configure_file Problem configuring file\nCall Stack (most recent call first):\n  CMakeLists.txt:2 (project)\n\n\n-- Check for working C compiler: /usr/bin/cc\n-- Check for working C compiler: /usr/bin/cc -- works\n-- Detecting C compiler ABI info\n-- Detecting C compiler ABI info - failed\n-- Detecting C compile features\n-- Detecting C compile features - done\nCMake Error at /usr/local/share/cmake-3.16/Modules/CMakeTestCCompiler.cmake:80 (configure_file):\n  configure_file Problem configuring file\nCall Stack (most recent call first):\n  CMakeLists.txt:2 (project)\n\n\n-- Check for working CXX compiler: /usr/bin/c++\n-- Check for working CXX compiler: /usr/bin/c++ -- works\n-- Detecting CXX compiler ABI info\n-- Detecting CXX compiler ABI info - failed\n-- Detecting CXX compile features\n-- Detecting CXX compile features - done\nCMake Error at /usr/local/share/cmake-3.16/Modules/CMakeTestCXXCompiler.cmake:73 (configure_file):\n  configure_file Problem configuring file\nCall Stack (most recent call first):\n  CMakeLists.txt:2 (project)\n\n\n-- Configuring incomplete, errors occurred!\nSee also "/mnt/d/ATest/build/CMakeFiles/CMakeOutput.log".\nSee also "/mnt/d/ATest/build/CMakeFiles/CMakeError.log".\n(base) ciaran@DESKTOP-K0APGUV:/mnt/d/ATest/build$\n
Run Code Online (Sandbox Code Playgroud)\n

我最初尝试了 cmake 3.15,但升级后看看是否是版本问题,考虑到这一点,我不这么认为。我也尝试过g++-7并且g++-9其行为相同。

\n

有人知道这里会发生什么吗?谢谢。

\n

Pet*_*ter 7

  1. wsl.conf使用以下文本在 /etc/ 中创建一个名为的文件:
# /etc/wsl.conf
[automount]
options = "metadata"
enabled = true
Run Code Online (Sandbox Code Playgroud)
  1. 重新启动 wsl:

wsl.exe -t Ubuntu // (or other e.g. Debian)

资料来源:

  • 是的,这解决了它。@squareskittles 发布的链接引导我找到相同的信息。为了完整起见,我将发布解决方案。 (2认同)