This theme is bui|

TomZz

园龄:2年7个月粉丝:1关注:1

📂Linux
2022-08-11 10:36阅读: 234评论: 0推荐: 0

Windows11下用WSL的原生GNU工具链来实现C系列程序的开发

事情的起因

cygwin和mingw-w64在Windows平台下始终无法解决编码问题,出现中文目录文件名可以运行但无法调试。Clion出现无法调和的bug。
故决定使用WSL获取原生的体验。

使用WSL2

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

下载安装Linux内核更新包

https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi

重启电脑
Microsoft Store安装Ubuntu22.04LTS
打开进行一些基本的配置

安装GNU工具链

sudo apt install gcc clang cmake gdb

Ubuntu库的cmake版本为3.22,而Clion需要的是3.23以上,当我安装最新的3.24又显示不支持🤣,所以下载Github编译好的3.23的包
https://github.com/Kitware/CMake/releases

wget https://github.com/Kitware/CMake/releases/download/v3.23.3/cmake-3.23.3-linux-x86_64.tar.gz
tar -zxvf cmake-3.23.3-linux-x86_64.tar.gz
# 创建软链接
sudo ln -s /mnt/c/Users/Administrator/cmake-3.23.3-linux-x86_64/bin/cmake /usr/bin/cmake

Clion添加工具链中可以自动识别已安装的WSL

在VSCode中使用WSL

  1. 可以通过Remote-WSL插件通过SSH的方式连接到WSL
  2. 通过CodeRunner等的配合
    以下为settings.json中的终端配置(必须按照terminal.integrated.defaultProfile.windows的提示书写名称)
  "terminal.integrated.profiles.windows": {
    "PowerShell": {
      "path": "pwsh.exe",
      "args": [
        "-nologo"
      ]
    },
    "Ubuntu-22.04 (WSL)": {
      "path": "wsl.exe",
      "args": []
    }
  },
  "terminal.integrated.defaultProfile.windows": "Ubuntu-22.04 (WSL)",

以下为CodeRunner的map的书写

# 必须加的一条路径指定
  "code-runner.terminalRoot": "/mnt/",
# code-runner自带的clear-output无法在终端生效
  "code-runner.executorMap": {
    "c": "clear && cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
},

以下为调试的配置的书写

~~~
因觉得不想让WSL污染本地开发环境,故停止继续研究😂

记录参考资料

Win10配置Clion+WSL2开发环境
VSC+WSL

本文作者:TomZz

本文链接:https://www.cnblogs.com/Tom-Zz/p/16574976.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   TomZz  阅读(234)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起
  1. 1 Different World Alan Walker,K-391,CORSAK胡梦周,Sofia Carson
  2. 2 Wild Wild Web John The Whistler
  3. 3 In the End Linkin Park
  4. 4 Leave Out All The Rest Linkin Park
Different World - Alan Walker,K-391,CORSAK胡梦周,Sofia Carson
00:00 / 00:00
An audio error has occurred, player will skip forward in 2 seconds.

作词 : Gunnar Greve/SHY Martin/Magnus Bertelsen/Fredrik Borch Olsen

作曲 : Gunnar Greve/Alan Walker/SHY Martin/Kenneth Nilsen/Magnus Bertelsen/Fredrik Borch Olsen/Marcus Arnbekk/Mengzhou Hu/James Daniel Njie Eriksen

All we know

Left untold

Beaten by a broken dream

Nothing like

What it used to be

We’ve been chasing our demons down an empty road

Been watching our castle turning into dust

Escaping our shadows just to end up here once more

And we both know

This is not the world we had in mind

But we got time

We are stuck on answers we can’t find

But we got time

And even though we might have lost tonight

The skyline reminds us of a different time

This is not the world we had in mind

But we got time

Broken smiles

Tired eyes

I can feel your longing heart

Call my name

Howling from afar

We’ve been fighting our demons just to stay afloat

Been building our castle just to watch it fall

Been running forever just to end up here once more

And now we know

This is not the world we had in mind

But we got time

We are stuck on answers we can’t find

But we got time

And even though we might have lost tonight

The skyline reminds us of a different time

This is not the world we had in mind

But we got time

Take me back

Back to the mountain side

Under the northern lights

Chasing the stars

Take me back

Back to the mountain side

When we were full of life

Back to the start

We both know that

This is not the world we had in mind

But we got time

We are stuck on answers we can’t find

But we got time

And even though we might have lost tonight

The skyline reminds us of a different time

This is not the world we had in mind

But we got time