如何在CLion中使用WSL

3
我正在尝试按照https://www.jetbrains.com/help/clion/how-to-use-wsl-development-environment-in-clion.html#上的说明,设置CLion使用Windows子系统来进行Linux开发环境。我的Windows版本是10.0.18362.836,Ubuntu版本是20.04 LTS,所有软件均为最新版本。
在“Build, Execution, Deployment > Toolchains”页面的“Settings Dialog”中,我遇到了以下错误报告: Test CMake run finished with error more... 详情请见...
CMake Error at /usr/share/cmake-3.16/Modules/CMakeDetermineSystem.cmake:185 (configure_file):
  configure_file Problem configuring file
Call Stack (most recent call first):
  CMakeLists.txt:1 (project)


-- The C compiler identification is GNU 9.3.0
CMake Error at /usr/share/cmake-3.16/Modules/CMakeDetermineCCompiler.cmake:212 (configure_file):
  configure_file Problem configuring file
Call Stack (most recent call first):
  CMakeLists.txt:1 (project)


-- The CXX compiler identification is GNU 9.3.0
CMake Error at /usr/share/cmake-3.16/Modules/CMakeDetermineCXXCompiler.cmake:210 (configure_file):
  configure_file Problem configuring file
Call Stack (most recent call first):
  CMakeLists.txt:1 (project)


-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Detecting C compile features
-- Detecting C compile features - done
CMake Error at /usr/share/cmake-3.16/Modules/CMakeTestCCompiler.cmake:80 (configure_file):
  configure_file Problem configuring file
Call Stack (most recent call first):
  CMakeLists.txt:1 (project)


-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at /usr/share/cmake-3.16/Modules/CMakeTestCXXCompiler.cmake:73 (configure_file):
  configure_file Problem configuring file
Call Stack (most recent call first):
  CMakeLists.txt:1 (project)


-- Configuring incomplete, errors occurred!
See also "/mnt/c/Users/user/AppData/Local/Tmp/cmake_check_environment/_build2367382020510955708/CMakeFiles/CMakeOutput.log".
See also "/mnt/c/Users/user/AppData/Local/Tmp/cmake_check_environment/_build2367382020510955708/CMakeFiles/CMakeError.log".

Error code: 1

我该怎么做来解决这个问题?

3个回答

4

我在使用WSL 2和Ubuntu 20.04.1时遇到了相同的问题。

问题似乎是Ubuntu WSL和Windows Host机器的处理器时钟略微不同步造成的。

CMakeError.log:

make: Warning: File 'CMakeFiles/cmTC_823ef.dir/flags.make' has modification time 0.046 s in the future
make: warning:  Clock skew detected.  Your build may be incomplete.

通过 wsl --shutdownwsl 命令重新启动WSL 可以修复该问题。

可在此处找到解决该问题的方法:https://github.com/microsoft/WSL/issues/4677


1

首先检查您是否安装了所有依赖项

sudo apt-get install cmake gcc clang gdb build-essential

那么您应该在Ubuntu终端上配置ssh服务器。如果您能够自己完成,那太好了!您不需要做任何其他操作,但如果您无法完成,请使用JetBrains脚本。

在工具链部分连接到您的ssh会话。

但在审查后,我注意到编译器在底部为您提供了一个日志文件,以获取更多信息,请将其发送到此处,并尝试重新安装软件包,这通常可以解决问题。还有一个问题,您使用的是wsl 1还是2?WSL 2比1具有更多功能,但它有很多错误,对大多数程序员来说并不好,我不建议任何人使用。


我已确认它是WSL 1。 - J Vines
不幸的是,当我去查找日志文件时,cmake_check_environment目录不存在。我已经尝试使用Windows资源管理器和Bash来查找它。 - J Vines

0

你可以像安装普通Linux机器一样在WSL2中安装clion,然后创建一个可执行的powershel脚本,使用this仓库的指令从Windows端自动启动clion。

你需要已启用以下功能:

  • 在WSL2中安装了clion
  • here安装了XcXrv
  • 在powershel中启用ps2exe:Install-Module -Name ps2exe

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接