可以去Ubuntu自带的应用商店下载,或者使用命令行下载
直接下载的是英文版本,需要设置成中文显示
先去VS Code自带的商店下载插件,快捷键:Ctrl+Shift+x,搜索Chinese (Simplified) Language Pack for Visual Studio Code,点击下载;
然后配置语言,快捷键:Ctrl+Shift+p,在选框中输入configure display language,点击确定,在出现的locale.json文件中,将"locale":“en” 改为“locale”:“zh-CN”;
重启VSCode;
和第二步类似去VS Code自带的商店下载插件,快捷键:Ctrl+Shift+x,下载各种依赖包,包括:c/c++,c/c++ clang command adapter,c++ intellisense,CMake和CMake Tools
打开一个含有的完整的Cmake工程文件夹
在.vscode文件夹中要建立三个json文件才能对Cmake工程进行编译和调试,分别是c_cpp_properties.json,launch.json和tasks.json
ctrl+shift+p→C/Cpp: Edit Configurations(JSON),生成c_cpp_properties.json
{"configurations": [{"name": "Linux","includePath": ["${workspaceFolder}/**"],"defines": [],"compilerPath": "/usr/bin/gcc","cStandard": "c11","cppStandard": "c++17","intelliSenseMode": "clang-x64""compileCommands": "${workspaceFolder}/build/compile_commands.json"}],"version": 4
}
按F5,生成launch.json
{// Use IntelliSense to learn about possible attributes.// Hover to view descriptions of existing attributes.// For more information, visit: /?linkid=830387"version": "0.2.0","configurations": [{"name": "(gdb) 启动","type": "cppdbg","request": "launch","program": "${workspaceFolder}/build/application", //输入程序名称,例如 ${workspaceFolder}/a.out"args": ["test1", "test2"], //输入程序运行参数"stopAtEntry": false,"cwd": "${workspaceFolder}/build", //设置程序运行初始路径"environment": [],"externalConsole": false,"MIMode": "gdb","setupCommands": [{"description": "为 gdb 启用整齐打印","text": "-enable-pretty-printing","ignoreFailures": true}]}]
}
ctrl+shift+B→生成tasks.json
{// See /?LinkId=733558// for the documentation about the tasks.json format"version": "2.0.0","tasks": [{"label": "make build",//编译的项目名,build"type": "shell","command": "cd ./build ;cmake ../ ;make",//编译命令"group": {"kind": "build","isDefault": true}},{"label": "clean","type": "shell","command": "make clean",}]
}
例如:
cmake_minimum_required(VERSION 2.8)set(CMAKE_BUILD_TYPE "Debug")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -Wall -g -ggdb")
add_compile_options(-std=c++11)set(source ./block.h ./graph.h ./graph.cpp ./maxflow.cpp ./main.cpp)add_executable(maxflow ${source})
ctrl+shift+B 编译程序
F5 执行程序
在文件中添加
set(CMAKE_BUILD_TYPE "Debug")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -Wall -g -ggdb")
即可通过断点进行调试
本文发布于:2024-01-30 17:36:40,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170660740421702.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |