博主全网搜索过很多教程,各种碰壁不成功,最终使用了PowerShell成功的。本文将介绍PowerShell的成功方法和几个替代方案。博主使用WSL是Ubuntu 20.04 LTS
相关文献
PowerShell解决方案
首先我们打开WSL:
$ echo 'export TEMPORARY = /usr/local'>>~/.bashrc
$ echo 'WSLENV = $WSLENV:TEMPORARY powershell.exe'>>~/.bashrc
$ source ~/.bashrc
Windows PowerShell
版权所有 (C) Microsoft Corporation。保留所有权利。
尝试新的跨平台 PowerShell https://aka.ms/pscore6
PS Microsoft.PowerShell.Core\FileSystem::\\wsl$\Ubuntu-20.04\root>
$ cd 'C:\'
$ & 'C:\Program Files\JetBrains\CLion 2021.2.3\bin\clion.bat'
于是我们安装在windows上的CLion启动了,我们新建一个工程,然后在CMakeLists.txt:
cmake_minimum_required(VERSION 3.16)
project(PowerShell)
set(CMAKE_CXX_STANDARD 20)
add_executable(PowerShell main.cpp)
message(“TEMPORARY: $ENV{TEMPORARY}”)
我们Reload CMake Project 在CMake终端会输出:
C:\windows\system32\wsl.exe --distribution Ubuntu-20.04 --exec /bin/sh -c "export CLION_IDE=TRUE && export JETBRAINS_IDE=TRUE && cd /mnt/d/CWorks/PowerShell/cmake-build-debug && /usr/bin/cmake -DCMAKE_BUILD_TYPE=Debug -G 'CodeBlocks - Unix Makefiles' /mnt/d/CWorks/PowerShell; exitcode=$?; sleep 0.001; (exit $exitcode)"
“TEMPORARY:/usr/local”
-- Configuring done
-- Generating done
-- Build files have been written to: /mnt/d/CWorks/PowerShell/cmake-build-debug
[Finished]
如果你输出的是乱码如下:
C:\windows\system32\wsl.exe --distribution Ubuntu-20.04 --exec /bin/sh -c "export CLION_IDE=TRUE && export JETBRAINS_IDE=TRUE && cd /mnt/d/CWorks/PowerShell/cmake-build-debug && /usr/bin/cmake -DCMAKE_BUILD_TYPE=Debug -G 'CodeBlocks - Unix Makefiles' /mnt/d/CWorks/PowerShell; exitcode=$?; sleep 0.001; (exit $exitcode)"
鈥淭EMPORARY:/usr/local鈥�
-- Configuring done
-- Generating done
-- Build files have been written to: /mnt/d/CWorks/PowerShell/cmake-build-debug
[Finished]
那么请参考博主的另一篇编码设置问题: CLion 中文编码设置(UTF8、GBK)(Windows、WSL)——持续更新ing
|