Posts with tag windows

connect usb

2024-10-28
oswindowswsl

connect usb首先参考官方 : https://learn.microsoft.com/zh-cn/windows/wsl/connect-usb#attach-a-usb-device.再使用本文中的 chmod 和简易 test.py 测试 : https://blog.csdn.net/weixin_37210821/article/details/135137942如果失败,则执行本文的编译内核,其中内核 tag 版本号可修改为 uname -a 中的版本24.10.28,先重装内核再执行 ms 官方的挂载命令,可通过 test.py 测试每次重启电脑后,均需要# 管理员 powershell usbipd list usbipd bind --busid <busid, ex: 4-4> usbipd attach --wsl --busid <busid> # wsl sudo chmod 777 /dev/video* # 查看有无 ls /dev/video* lsusbimport cv2 W=640 H=480 cap = cv2.VideoCapture(0) # 可能需要改,改此运行成功 24.11.26 cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc('M','J','P','G')) #cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc('Y','U','Y','V')) cap.set(cv2.CAP_PROP_FRAME_WIDTH, W) cap.set(cv2.CAP_PROP_FRAME_HEIGHT, H) cap.set(cv2.CAP_PROP_FPS, 30) while True: ret, frame = cap.read() if not ret: continue cv2.imshow('usb cam test', frame) if cv2.waitKey(1) & 0xFF == ord('q'): break cap.release() cv2.destroyAllWindows(

Setup clangd, cmake just like on unix

2024-07-03
softwares-and-toolsvscodewindows

Setup clangd, cmake just like on unixref: https://blog.csdn.net/tyKuGengty/article/details/120119820 (not reliable) ref: https://www.perplexity.ai/search/windows-shang-ru-he-huo-qu-he-UAy020tWRWG50tRSmDYuIw#0Don'tDon't use clangd exe downloaded by clangd extension in vscode.Don't need tasks.json like files.StepsInstall msys2 https://www.msys2.org/Install C++ toolchainpacman -Syu pacman -S mingw-w64-x86_64-gcc pacman -S mingw-w64-x86_64-cmake # use cmake --build ., no need make pacman -S mingw-w64-x86_64-clang pacman -S mingw-w64-x86_64-clang-tools-extra # clangd is hereFind your clangd.exe in C:\msys64\mingw64\clangd.exePut the path in your vscode clangd settings.Done.TestCreate unix like cmake projectcd buildcmake ..Reload vscode window and see if it can find headersIf you want lsp without cmakeAdd this two flags to your vscode clangd fallback flags:-IC:/msys64/mingw64/include/c++/14.1.0 --target=x86_64-w64-windows-gnucheck if a single file can find headers.(Tested ok)Use ninjaIn msys2:pacman -S mingw-w64-x86_64-ninjaWrite cmake as usual. ref: https://blog.51cto.com/u_15127539/3336648cd build # I forget if I need to specify "build for ninja". This just works on my win10 now cmake .. ninja installGo to install/bin/ and check generated executable

Install wsl and use cmake in vscode

2024-04-29
oswin11windowswslwsl2

Install wsl and use cmake in vscode假设您在 win11 下。安装 wsl,ref: https://zhuanlan.zhihu.com/p/475462241其实大多数 win11 电脑只需要在 PowerShell 中执行以下,等待安装(进度条可能显示 0% 很久):wsl --install -d Ubuntu24.6.28 win10 此命令安装时提示网络相关错误,重新试了好几次居然安装好了。 24.6.28 下载完他让我重启,重启后需要手动输入 ubuntu 才会开始安装。此时相当于在你的 windows 里安装一个 ubuntu,默认安装 Ubuntu 22.04。接下来它会自动创建 ubuntu 的管理员用户,让你输入用户名。所以你就输入管理员用户名和密码,完成安装,关闭 PowerShell在 Windows 的 vscode 中安装插件 WSLctrl + shift + p 打开 vscode 命令面板,执行 WSL: 连接到 WSL,此时自动打开新窗口在新窗口中 ctrl + shift + e 选择一个文件夹按 ctrl + j 打开终端执行 sudo vim /etc/apt/source.list,删除原有内容,添加下面链接中的镜像链接:https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/这一步是准备 cmake 的下载源。以下是 24.4.30 可用的 Ubuntu 22.04 apt 源:# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释 deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse deb http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse # deb-src http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse # 预发布软件源,不建议启用 # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse # # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse安装 cmake:sudo apt update # 更新下载源 sudo apt install cmake现在你可以在 vscode 中的终端窗口中的 wsl ubuntu 命令行中正常使用 cmake 了打开 win11 - 文件管理器,可以看到左侧栏目中有一个 Linux,这就是 wsl 所在的位置。你可以把 win11 的文件拖动到 Linux - Ubuntu - home - 用户名 文件夹中,也可以拖动到 vscode 打开 wsl 后的资源管理器中

No more posts to load.