This theme is built with|

TomZz

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

📂Linux
2022-08-11 10:36阅读: 233评论: 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  阅读(233)  评论(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
Wild Wild Web - John The Whistler
00:00 / 00:00
An audio error has occurred, player will skip forward in 2 seconds.

It's a wild wild web when you feel lost inside

the wild wild web where there's nothing to hide

on the wild wild web please tell me where I'll find

virtual reality of your smile

It's a changing world that we're living today

It's a changing world that we're living today

If you need a girl there's a very new way

If you need a girl there's a very new way

You're chatting all alone on the web

You're chatting all alone on the web

declaring all your love on the net

It's a wild wild web when you feel lost inside

the wild wild web where there's nothing to hide

on the wild wild web please tell me where I'll find

virtual reality of your smile

From my bottom I prefer the old fashion way

From my bottom I prefer the old fashion way

When to flirt with a girl you just go for a date

When to flirt with a girl you just go for a date

but all I gotta view is your mail

but all I gotta view is your mail

so stay connected just don't run away

It's a wild wild web when you feel lost inside

the wild wild web where there's nothing to hide

on the wild wild web please tell me where I'll find

virtual reality of your smile

It's a wild wild web when you feel lost inside

It's a wild wild web when you feel lost inside

the wild wild web where there's nothing to hide

on the wild wild web please tell me where I'll find

virtual reality of your smile

Now I hope that some day we will be meeting for real

And we talk and we laugh having some Indian meal

And we talk and we laugh having some Indian meal

I hope that good time at last

I hope that good time at last

cause Gs I found are most just too fast

It's a wild wild web when you feel lost inside

the wild wild