侧边栏壁纸
  • 累计撰写 125 篇文章
  • 累计创建 16 个标签
  • 累计收到 4 条评论

目 录CONTENT

文章目录

VsCode 使用汇总

C++头文件自动检索

为了方便代码检索,以及不是一片红,头文件自动检索是十分必要的。

  • 安装 C/C++ 扩展,扩展将为每个工作空间创建一个 .vscode/c_cpp_properties.json 文件。
  • 如果项目使用的是 CMake 进行编译,在 CMakeLists.txt 中,添加以下行:
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
  • 然后,在 .vscode/c_cpp_properties.json 文件中,设置 compileCommands 为该文件的路径,如:
"compileCommands": "${workspaceFolder}/build/compile_commands.json"
  • 这会将编译过中的所有依赖和头文件收集起来,例如:
{
  "directory": "/home/sibl/Codes/MultiKinectCalib/build",
  "command": "/usr/bin/aarch64-linux-gnu-g++ -DDISABLE_LIBUSB_1_0 -DDISABLE_PCAP -DDISABLE_PNG -Dqh_QHpointer -DvtkRenderingContext2D_AUTOINIT=\"1(vtkRenderingContextOpenGL2)\" -DvtkRenderingCore_AUTOINIT=\"3(vtkInteractionStyle,vtkRenderingFreeType,vtkRenderingOpenGL2)\" -I/home/sibl/Codes/MultiKinectCalib/include -isystem /usr/include/vtk-7.1 -isystem /usr/include/freetype2 -isystem /usr/include/opencv4 -isystem /usr/include/pcl-1.10 -isystem /usr/include/eigen3 -isystem /usr/include/ni -isystem /usr/include/openni2   -Wall -g -o CMakeFiles/main.dir/src/main.cpp.o -c /home/sibl/Codes/MultiKinectCalib/src/main.cpp",
  "file": "/home/sibl/Codes/MultiKinectCalib/src/main.cpp",
  "output": "CMakeFiles/main.dir/src/main.cpp.o"
}

conda环境无法检索

在vscode直接执行 python 文件时出现报错,无法检索 conda:

conda : 无法将“conda”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,
如果包括路径,请确保路径正确,然后再试一次。
所在位置 行:1 字符: 1
+ conda activate dp
+ ~~~~~
    + CategoryInfo          : ObjectNotFound: (conda:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

这是因为我们的 powershell 没有设置好,首先在 cmd 终端中执行:

conda init powershell

另外,请确保你的 PowerShell 的执行策略允许运行这个 profile.ps1 脚本:

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
0

评论区